[CSS] id vs class
Discussion
Classes are used when you need to assign a style to any number of elements. IDs are supposed to be used only once in a document. So;
.highlight {color: yellow;}
<h1 class="highlight">HighlightedHead!</h1>
<p class="highlight">some highlighted text</p>
---
{#content_main {width: 70%;}}
<div id="content_main">
main content stuff
</div>
(ignore outer set of braces in content_main id above; PH formatting)
.highlight {color: yellow;}
<h1 class="highlight">HighlightedHead!</h1>
<p class="highlight">some highlighted text</p>
---
{#content_main {width: 70%;}}
<div id="content_main">
main content stuff
</div>
(ignore outer set of braces in content_main id above; PH formatting)
Edited by .Flyer on Tuesday 26th June 20:11
No, there are hard and fast rules, but most browsers attempt to Do What You Mean, which is very wrong in my opinion.
http://www.w3schools.com/css/default.asp is good, links to the specs and things from there too.
http://www.w3schools.com/css/default.asp is good, links to the specs and things from there too.
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


