CSS is a mechanism to control the appearance of web pages. It can be used to control the font, color, layout, spacing, and border of webpages.
CSS is divided into three types:
1. inline style: The style is directly written to a specific HTML tag in the form of attributes.
<TD style = "border: 1 solid black"> Hello </TD>
2. embedded style: it is written in the
<Style type = "text/CSS">
. TD {color: red; font-size: Large ;}
</Style>
<TD style = "TD"> Hello </TD>
3. external style: Write all styles to one *. in the CSS file, use the following syntax in the
Use CSS:
Code
1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
2 < Html Xmlns = "Http://www.w3.org/1999/xhtml" >
3 < Head >
4 < Title > No title page </ Title >
5 < Style Type = "Text/CSS" >
6 Dd { Color : Red ; }
7 . Dt { Color : Blue ; }
8 # DD1 { Color : Darkgreen ; }
9 </ Style >
10 </ Head >
11 < Body >
12 < DL >
13 < DT Class = "DT" > Root </ DT >
14 < Dd ID = "DD1" > Child1 </ Dd >
15 < Dd > Child2 </ Dd >
16 < Dd > Child3 </ Dd >
17 < Dd > Child4 </ Dd >
18 < Dd > Child5 </ Dd >
19 < Dd > Child6 </ Dd >
20 </ DL >
21 </ Body >
22 </ Html >
23
1) A style (type selector) with "." Must be called in a specific HTML Tag, class = "style name"
2) A style (ID selector) with "#" is automatically valid for tags with characters whose ID is "#" in the current HTML.
3) A style (TAG selector) with no "." or "#" characters is automatically valid for tags with the same style name in the current HTML.
The result is as follows: