HTML and CSS Reference
In-Depth Information
in the United States" />
5. <ul>
6. <li>234 square miles</li>
7. <li>2.715 million residents</li>
8. </ul>
9. </ASIDE>
GOOD CODE
Click here to view code image
1. <aside>
2. <h3>Chicago</h3>
3. <h5 hidden>City in Illinois</h5>
4. <img src="chicago.jpg" alt="Chicago, the third most populous city
in the United States">
5. <ul>
6. <li>234 square miles</li>
7. <li>2.715 million residents</li>
8. </ul>
9. </aside>
Use Practical ID & Class Values
Creating ID and class values can be one of the more difficult parts of writing HTML. These
values need to be practical, relating to the content itself, not the style of the content. Using
a value of red to describe red text isn't ideal, as it describes the presentation of the content.
Should the style of the text ever need to be changed to blue, not only does the CSS have to
be changed, but so does the HTML in every instance where the class red exists.
The HTML here assumes that the alert message will be red. However, should the style of
the alert change to orange the class name of red will no longer make sense and will likely
cause confusion.
BAD CODE
Click here to view code image
1. <p class="red">Error! Please try again.</p>
GOOD CODE
Click here to view code image
1. <p class="alert">Error! Please try again.</p>
Search WWH ::




Custom Search