Css usage and css usage

Source: Internet
Author: User

Css usage and css usage

Css (Cascading Style Sheet) is a page beautification method. By editing Css object attributes, You can beautify the page. The basic unit of Css operations is an object. CSS is like a function in C ++/C. CSS objects are like functions. They are used by definition, declaration, and call.

 

CSS has three selectors (object definition and usage): Tag selector, category selector, and ID selector.

CSS has four methods: inline, link, and pilot

 

Tag selector:

Definition: referenced style object name {tag property: property value ;.......}

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

Use:

<H2> ........ </H2>

CATEGORY selector:

Definition: Tag name. Class Name {tag property: attribute value ;.......} Or

. Class Name {tag attribute: attribute value ;.......}

Eg: p. center {text-align: center ;}

. Right {text-align: right ;}

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

<H1 class = "right"> ........ </H1>

(* Difference: the last format indicates that all labels with class attribute values being class names comply with the style defined by this class)

(Eg: Defines. right {text-align: right;}. When calling, as long as the label of the right attribute is called through the class, the right attribute can be displayed. <H2 class = "right"> ..... </H2>; <p class = "right"> ...... </P>; <span class = "right"> ...... </Span>; labels and so on all show right-aligned attributes. )

ID selector:

Definition: # id name {tag attribute: attribute value ;.......}

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

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

 

Inline style:

You do not need to define the selector. You can use the style attribute to directly design the style for the element.

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

Embedded:

Define the selector first and define the style sheet between

Eg:

 

 

 

Link:

The defined object is stored in a file with the extension .css. When you use the <link> label to link to the desired webpage, the object is placed between

Eg: <link href?”xxx.css "type =" text/css "rel =" stylesheet ">

Import:

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

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

 

CSS style sheet priority:

Embedded style sheet> inline> external> browser default

16:28:52

Related Article

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.