The reason to use id and not class should be self-evident: we have just one single element in our HTML page that we want to comply with a very specific style. For instance, we could use it for the page footer:
<p id="footer">Please steal this page, it isn't copyrighted in any way</p>In the CSS we write:
#footer { color: red; }We can be even more specific, and say that the style is defined for the footer attribute on a paragraph element:
p#footer { color: red; }
A fun book for HTML beginners: Head First HTML.
No comments:
Post a Comment