This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Dreamweaver > March 2005 > CSS question IDs and Class
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
CSS question IDs and Class
|
|
| Anthony LeBaron 2005-03-08, 6:40 pm |
| Slogging through CSS and slowly making the transition away from tables.
Understand the diff between IDs (#style) which are unique to an element, and
Class (.style) which can be used on multiple elements. But I can't
understand why you would choose to use the ID tag, when it would be just as
simple to use a class and use it only once.
Is this a dumb question? I dunno.
| |
| Michael Fesser 2005-03-08, 6:41 pm |
| .oO(Anthony LeBaron)
>Slogging through CSS and slowly making the transition away from tables.
>
>Understand the diff between IDs (#style) which are unique to an element, and
>Class (.style) which can be used on multiple elements. But I can't
>understand why you would choose to use the ID tag, when it would be just as
>simple to use a class and use it only once.
There's much more about IDs. They identify an element, so that this
element can be accessed directly and manipulated with client-side
scripting (DOM, document object model).
Additionally ID selectors are more specific than anything else, which
becomes an issue when more than one selector apply to an element
(cascading rules), e.g.
#foo {color: red}
..foo {color: blue}
<p id='foo' class='foo'>...</p>
Both selectors apply to the paragraph, what will be its color? It will
be red, because #foo is more specific than .foo and will override it.
Micha
| |
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|