Usage of CSS

Source: Internet
Author: User
Tags tag name

CSS (cascading style Sheets, cascading style sheets) is a way to beautify the page by editing the object properties of the CSS. The basic element of the operation of the CSS is the object, the use of CSS is like using a function in c++/c, CSS object is like a function, by definition, declaration, the use of the tune.

CSS has three selectors (object definition and how to use): Tag Selector, category selector, ID selector

CSS has four methods: inline, inline, linked, import

Tag Selector:

Definition: Referenced style object name {tag attribute: attribute value; Tag attribute: property value; ...}

Eg:h1,h2{text-align:center; color:red;}

Using:

Category selector:

Definition: Tag name. class Name {tag attribute: attribute value; Tag attribute: property value; ...} or

. class Name {tag attribute: attribute value; Tag attribute: property value; ...}

eg:p.center{Text-align:center;}

. right{Text-align:right;}

Use: <p class= "center" >........</p>

(* difference: The latter format indicates that all tags of the class attribute value are in accordance with the style defined by the class)

(eg: defines the. right{text-align:right;}, when called, the property of right can be displayed as long as it is a label of the property that is called by class. <H2 class= "right" >..... <span class= "right" >......</span>; and so on, the labels all show the properties that are aligned. )

ID selector:

Definition: #id名称 {Tag Property: property value; Label property: Property value; ...}

Eg: #sample {font-family: Song body; don ' t-size:60pt;}

Use: <p id=sample>......</p>

In-line:

You do not need to define selectors and use the style property to design styles directly for elements

Eg: <p style= "color: #FF0000" >......</P>

Inline type:

Define the selector to define the style sheet between

eg

<HTML>        <Head>           <title>Xxxxxx</title>            <styletype= "Text/css">P{Color:#000FF;}. Info{font-size:12px;}</syle> 

LINK Type:

The defined objects are placed separately in a file with a. css extension, in the use <link> tags link to the desired page, between

Eg: <link href= "Xxx.css" type= "Text/css" rel= "stylesheet" >

Import Type:

Similar to a linked method, it is imported only through the import method.

Eg: <style type= "text/css" > @import url (xxx.css);</style>

Precedence of CSS style sheets:

Inline style sheet > inline > External > Browser default

16:28:52 2016-10-07

Usage of CSS

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.