A div is like a blank container. To set the properties of a div, we’ll associate it a class or an id and then set the properties for that class / id.
If we want to use the properties on more than one div, we’ll use classes. Otherwise, we’ll use ids.
In the CSS file, class names start with . while ids names start with #.
Using classes:
Using ids:
If we want to use the properties on more than one div, we’ll use classes. Otherwise, we’ll use ids.
In the CSS file, class names start with . while ids names start with #.
Using classes:
- in the HTML file
Code:<div [B]class = "common"[/B]> ... div's content ... </div>
- in the CSS file
Code:[B].common[/B] { color : blue; }
Using ids:
- in the HTML file
Code:<div [B]id = "unique"[/B]> ... div's content ... </div>
- in the CSS file
Code:[B]#unique[/B] { color : blue; }