The id attribute is used to identify elements and mark up specific functional areas of a
website, and the class attribute is used to classify one or more elements. These important
attributes help you target elements when it comes to styling or scripting. I refer to both of
these attributes throughout the book, but for now all you need to know is that a specific
id attribute value can be used just once per page, whereas a class attribute value can be
used multiple times (the attributes themselves can be used multiple times per page). For
example, say you begin a document with this:
<body id="homepage">
You would then not be able to use an id attribute value of homepage anywhere else on the
same page. However, if you do this:
<body class="homepage">
then you are free to use the class attribute value of homepage as many times as you like
throughout the same page, but bear in mind that it still applies the same CSS, no matter
what tag you apply it to.
<div id="rightColumn">
<strong class="redText">
<p class="big">
website, and the class attribute is used to classify one or more elements. These important
attributes help you target elements when it comes to styling or scripting. I refer to both of
these attributes throughout the book, but for now all you need to know is that a specific
id attribute value can be used just once per page, whereas a class attribute value can be
used multiple times (the attributes themselves can be used multiple times per page). For
example, say you begin a document with this:
<body id="homepage">
You would then not be able to use an id attribute value of homepage anywhere else on the
same page. However, if you do this:
<body class="homepage">
then you are free to use the class attribute value of homepage as many times as you like
throughout the same page, but bear in mind that it still applies the same CSS, no matter
what tag you apply it to.
<div id="rightColumn">
<strong class="redText">
<p class="big">