Classification of CCS (Cascading Style Sheets)

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.