Re: [css-d] ID vs. Class
On 19-Jul-10 23:26, Beth Lee wrote: ...but you can use getElementsByClassName. That wasn't available in IE, the last I heard. Has that changed? Reese __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
[css-d] ID vs. Class
Hi, I understand the difference between class and ID to a basic level. I am adding a #div but I may want to add another later. Therefore I should use class but what is the danger if I use a class - is it slower, does something cache that may not if it's an ID - what's the real difference other than using it once or multiple times? TY, CB __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs. Class
-Original Message- From: css-d-boun...@lists.css-discuss.org [mailto:css-d-boun...@lists.css-discuss.org] On Behalf Of Chris Blake Sent: Monday, July 19, 2010 8:50 PM To: css discuss discuss Subject: [css-d] ID vs. Class I understand the difference between class and ID to a basic level. ... - what's the real difference other than using it once or multiple times? 1. If you use an ID multiple times, your HTML won't validate. Maybe you don't care about that. 2. There is a difference between ID and class in the cascade in css. If a div has both a class and an ID, the ID rule trumps the class rule, since an ID has more specificity than a class, You can use the cascade to streamline your stylesheet. 3. If you use Javascript, your getElementById functions could go blooey if there are multiple divs with the same ID. (If there's a more technical terms for it, I don't know it.) Beth __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs. Class
On 20/07/2010, at 11:06 AM, Beth Lee wrote: -Original Message- From: css-d-boun...@lists.css-discuss.org [mailto:css-d-boun...@lists.css-discuss.org] On Behalf Of Chris Blake Sent: Monday, July 19, 2010 8:50 PM To: css discuss discuss Subject: [css-d] ID vs. Class I understand the difference between class and ID to a basic level. ... - what's the real difference other than using it once or multiple times? 1. If you use an ID multiple times, your HTML won't validate. Maybe you don't care about that. I do care. 2. There is a difference between ID and class in the cascade in css. If a div has both a class and an ID, the ID rule trumps the class rule, since an ID has more specificity than a class, You can use the cascade to streamline your stylesheet. Aha I learnt that. Forgot to say. 3. If you use Javascript, your getElementById functions could go blooey if there are multiple divs with the same ID. (If there's a more technical terms for it, I don't know it.) But it's OK if they classes? Beth Really for this because it is only appearing once for now I should use ID - but there's a good chance I may use it again later on this page - so class for now is OK? Cool and thank you. __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs. Class
Chris writes: 3. If you use Javascript, your getElementById functions could go blooey if there are multiple divs with the same ID. (If there's a more technical terms for it, I don't know it.) But it's OK if they classes? Well, you can't use getElementById (obviously), but you can use getElementsByClassName. Really for this because it is only appearing once for now I should use ID - but there's a good chance I may use it again later on this page - so class for now is OK? Sounds like class is the way to go. Beth __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs. Class
On Mon, Jul 19, 2010 at 8:15 PM, Chris Blake ch...@3pointdesign.com wrote: Really for this because it is only appearing once for now I should use ID - but there's a good chance I may use it again later on this page - so class for now is OK? I like to treat class and id semantically -- or at least according to my understanding of what that means. ID is properly used on elements (div, etc) that are unique. Class is used with elements that are categorical or a class in the mathematical and programming sense. For me an ID is something like header, footer, masthead, basically anything that makes sense as unique. If I happen to have a page for which I currently only have one newsitem. I will still use class. Simply because to me a page could naturally have more than one newsitem. I don't base the notion of ID simply on the fact of there being only one element of that type currently. I base it on there should rightfully be only one. This is how I go about it. As they say your mileage may vary. Regards, Claude Needham __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs. Class [solved]
On 20/07/2010, at 11:32 AM, Claude Needham wrote: On Mon, Jul 19, 2010 at 8:15 PM, Chris Blake ch...@3pointdesign.com wrote: Really for this because it is only appearing once for now I should use ID - but there's a good chance I may use it again later on this page - so class for now is OK? I like to treat class and id semantically -- or at least according to my understanding of what that means. ID is properly used on elements (div, etc) that are unique. Class is used with elements that are categorical or a class in the mathematical and programming sense. For me an ID is something like header, footer, masthead, basically anything that makes sense as unique. If I happen to have a page for which I currently only have one newsitem. I will still use class. Simply because to me a page could naturally have more than one newsitem. I don't base the notion of ID simply on the fact of there being only one element of that type currently. I base it on there should rightfully be only one. This is how I go about it. As they say your mileage may vary. Regards, Claude Needham SOUNDS GOOD TO ME! Cheers, CB __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs. Class [solved]
On Tuesday 20 July 2010 15:37, Chris Blake wrote: I like to treat class and id semantically -- or at least according to my understanding of what that means. SOUNDS GOOD TO ME! But there is nothing really wrong with a combination of both:- code div id=this1 class=content Content /div div id=this2 class=content More content /div /code This allows you to make these divs behave similar with the .content class, but give specific attributes to each as needed by ID. __ css-discuss [cs...@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
[css-d] ID vs Class
Why should class be used to define an element vs. id? I'm sure each one should be used in different situations, and would like more information on making the right choice. Do child elements inherit properties from there parent class? from there parent id? Any links to information on this topic would be much appreciated. Kind Regards, Travis Killen 936 Web Design http://936webdesign.com __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs Class
Technically, ids should only be declared once in a page, and classes can be repeated as many times as necessary. So I would declare page structure with ids and elements within as classes. If you have a button (for example) that is repeated many times in a page use a class. If you use Tidy (I use Safari Tidy) and repeat an id in a page it'll throw up a warning. There's more info here... http://creativebits.org/webdev/div_id_vs_div_class Why should class be used to define an element vs. id? I'm sure each one should be used in different situations, and would like more information on making the right choice. Do child elements inherit properties from there parent class? from there parent id? Any links to information on this topic would be much appreciated. Kind Regards, Travis Killen 936 Web Design http://936webdesign.com __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs Class
Travis Killen wrote: Why should class be used to define an element vs. id? You use ids for unique page elements. ie: id=contentWrapper id=mainNav id=inbox You use classes for styling similar elements. ie: class=externalLink class=topItem class=message However, you only need an id / class where there's no other way to distinguish an item. If you only have 1 form under contentWrapper you don't need to give it an id / class too. hth -- Thanks, Jim __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs Class
hi On 6/27/07, Travis Killen [EMAIL PROTECTED] wrote: Why should class be used to define an element vs. id? http://www.w3.org/TR/REC-CSS2/selector.html#id-selectors Any links to information on this topic would be much appreciated. http://www.w3.org/TR/REC-CSS2/cover.html#minitoc -- \js [ http://or8.net/~johns/ ] __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs Class
Travis Killen wrote: Why should class be used to define an element vs. id? I'm sure each one should be used in different situations, and would like more information on making the right choice. Do child elements inherit properties from there parent class? from there parent id? Any links to information on this topic would be much appreciated. Travis, We have a page on it in our wiki: http://css-discuss.incutio.com/?page=ClassesVsIds A quick reminder, while we're talking: To start a new thread, do not reply to an existing message. When you do this, your message gets threaded on to the old thread, which messes up the archives and makes it less likely that others will see your message and subsequently reply to you. You must send a new message with an appropriate and descriptive subject line to css-d@lists.css-discuss.org in order to start a new thread. Thanks, Zoe -- Zoe M. Gillenwater Design Services Manager UNC Highway Safety Research Center http://www.hsrc.unc.edu __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7 information -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
[css-d] ID vs Class
I am learning CSS and cannot distinguish between ID and Class. Please advise. Many thanks. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.394 / Virus Database: 268.7.1/347 - Release Date: 5/24/2006 __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs Class
hey there, Take a look at the following links: http://css-discuss.incutio.com/?page=ClassesVsIds http://developers.evrsoft.com/article/web-design/css/css-the-basics-id-s-and-classes.shtml Scott. Wintergreen wrote: I am learning CSS and cannot distinguish between ID and Class. Please advise. Many thanks. __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs Class
On 27/05/06, Wintergreen [EMAIL PROTECTED] wrote: I am learning CSS and cannot distinguish between ID and Class. Please advise. Many thanks. I don't think that is going to get much of a reponse as it is so basic that you could find it out on the web or in a book (not even a good book) in less than a minute! __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/ -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon! __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Re: [css-d] ID vs Class
On 5/27/06, Wintergreen [EMAIL PROTECTED] wrote: I am learning CSS and cannot distinguish between ID and Class. Just google on css id class. Google is your friend. -- Ed Seedhouse __ css-discuss [EMAIL PROTECTED] http://www.css-discuss.org/mailman/listinfo/css-d IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7 List wiki/FAQ -- http://css-discuss.incutio.com/ Supported by evolt.org -- http://www.evolt.org/help_support_evolt/