CSS Basic syntax

Source: Internet
Author: User

CSS is the abbreviation for cascading Style sheets, with the following basic structure:

<style type = "Text/css" >

selector {

property of Object 1: Property value 1;

Property of Object 2: Property value 2;

}

</style>

Where the selector represents the decorated object, and the property is the style that you want to change. Selectors can be divided into tag selectors, ID selectors, and class selectors.

1 Tag Selector

Suitable for decorating the contents of a class of labels on a page. The syntax is as follows:

Label name {

Property name 1: attribute value 1;

Property Name 2: attribute value 2;

.......

}

{                 color:red;                  Font-size:+;                  font-family: The song body ;              }        </style>   

Class 2 Selector

Tag Selector decorations are wide-ranging, and you can use a class selector if you want to decorate a specific <li> element individually. The syntax is as follows:

. class Name {

Property name 1: attribute value 1;

Property Name 2: attribute value 2;

.......

}

{Color:Red;font-size: +;font-family:Song Body; }. Blue{Color:Blue; }</style> 

3 ID Selector

The id attribute is a unique identifier for an HTML element and requires that the page cannot have duplicate ID identity attributes. The corresponding ID selector is typically used to decorate the HTML element content of the corresponding ID identifier, and the actual application is used in conjunction with </div> as follows:

<DIV id= "ID identification name" >.

The syntax is as follows:

#ID标识名 {

Property name 1: attribute value 1;

Property Name 2: attribute value 2;

......

}

{font-size:14px;font-family:Song Body;width:200px;background:#ccc; }</style> 

previously did not contact the CSS, while learning through the blog record, spur their own efforts, at the same time ask the blog park teachers criticize correct and many encouragement, thank you:)

CSS Basic syntax

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.