House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  Cascading Style Sheets (CSS)

Class prefixing

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Michael Dinowitz
04/18/2007 01:14 PM

Is it better to have classes as p.classname or .classname? Assuming that the classname will only be used with paragraphs. If tag prefixing is better, then does it apply to ids as well? #div.header instead of #header? Thanks

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Sandra Clark
04/18/2007 01:25 PM

Depends on what you want to do. A class that can be applied to all types of elements should be .classname.  That way it can be applied to any element that has the classname. p.classname will only be applied to paragraphs An id is unique to a page. So div#id and #id are semantically equivalent.   I tend to use the element name prior to the id for better documentation. Sandra Clark ============= http://www.shayna.com Training and Consulting  in CSS and Accessibility Team Fusebox Is it better to have classes as p.classname or .classname? Assuming that the classname will only be used with paragraphs. If tag prefixing is better, then does it apply to ids as well? #div.header instead of #header? Thanks

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Michael Dinowitz
04/19/2007 03:26 PM

Assuming a class will only be used for a single tag, is there any performance or other reason to prefix it? Also, will the tag prefixing of IDs fail on any browser or cause any problems? Will it have any performance effect? I like the idea of div#header for documentation sake. I know performance is not really a factor but when I see my browsers taking huge amounts of memory, I want to be sure that one of my sites is not contributing to that memory 'loss'. Less processing and/or less work by the browser is what I mean by performance, not really speed. Thanks ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Sandra Clark
04/19/2007 04:31 PM

It shouldn't cause a performance problem.   If you use .class rather than element.class for an item that only is supposed to be used on a single element, then you run the risk of someone, somewhere reusing that class on something else and having it mess up down the line.  My rule of thumb is that if it is only supposed to work with one element, then write it as such. Remember your CSS is cached, so its not a performance issue at all.  Pages done in this way actually give a better user experience in terms of speed since pages render faster anyways. Sandra Clark ============= http://www.shayna.com Training and Consulting  in CSS and Accessibility Team Fusebox Assuming a class will only be used for a single tag, is there any performance or other reason to prefix it? Also, will the tag prefixing of IDs fail on any browser or cause any problems? Will it have any performance effect? I like the idea of div#header for documentation sake. I know performance is not really a factor but when I see my browsers taking huge amounts of memory, I want to be sure that one of my sites is not contributing to that memory 'loss'. Less processing and/or less work by the browser is what I mean by performance, not really speed. Thanks ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Peter Boughton
04/18/2007 06:26 PM

For tags/ids... I agree entirely with Sasha. (it's not necessary but it can help with readability, especially when the id is not on a div) For tags/classes, I think we agree, but just wanted to post an example that I think clarifies things. Rather than "what you want to do", I think I'd say it depends on the context of the class. Example: <a class="external"...>...</a> - that's something that should be "a.external", because 'external' only really has meaning to a link. Compared to: <a class="new"...>...</a> - that should just be ".new" - because it's a class that could logically apply to non-links also, even if it never does, it still potentially has meaning outside of links. Does that make sense? ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search css

May 20, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference