|
If you want to change the appearance of a section on a page, you can use the <div> tag to define styles for that particular section. The following example uses the <div> tag to change the colour and point size of a block of text. This has the same effect as assigning these styles separately for the <p>, <ul>, and <li> tags: <div style="font-size: 10pt; color: red;"> <p>The style affects everything on this page until the div close tag.</p> <ul> <li>This is red and 10 pt.</li> <li>so is this.</li> </ul> </div> This looks like:
The following example uses the <div> tag for a block of text, but overrides it for a specific <li> tag: <div style="font-size: 10pt; color: red;"> <p>The style specification affects everything on this page until the DIV close tag, except for the second list item.</p> <ul> <li>This is red and 10 pt.</li> <li style="color: blue;">This is blue and 10 pt.</li> </ul> </div> This looks like:
|
More information Use the class attribute as a selector Use the id attribute as a selector Matching attributes and selectors Pseudo classes and elements as selectors Using the <div> tag to set a style |