HTML introduced CSS style three methods and the style of precedence CSS

Source: Internet
Author: User

HTML introduced CSS style three ways and priority:

Method

CSS style references are made in 3 different ways. inline style, inner style (inline), and external style, respectively;

Inline style: Use the object's Style property within the object's markup to define the applicable style sheet properties, defined as: <div style= "Content" ><div>;

Internal style (embedded): is the <style></style> tag pair placed in

External style: is to put the CSS file outside the Web page, through the link <link> make CSS file on this page style valid, <link type= "Text/css" rel= "stylesheet" href= "CSS File storage Address ">;

Priority: The top of the line style, the inner style (embedded) second, the external style has the lowest priority;

How CSS styles are written:

Each property has a value. Attributes and values are separated by colons; If you want to define more than one attribute, you need to separate each declaration with a semicolon;

Classification:

1. Group selector:

The grouped selectors can share the same declaration, separating the selectors that need to be grouped by commas;

H1,h2,h3,h4,h5,h6 {  color: Green;}

2. Descendant selector:

The style is defined by the context of the element in its position;

Li Strong {    font-style: italic;    Font-weight: normal;}

3. ID selector:

The ID selector is defined as "#";

# red {color:red;} # green {color:green;}

4. Class selector :

. center {Text-align:center;}

5, Pseudo-class selector:

<a></a>

a:link {color:red;}
a:visited {color:green;}

6. Inheritance:

The child element inherits the style of the parent element, and the child elements of the child element also inherit the style, and if they do not want to be inherited, their CSS style is rewritten;

HTML introduced CSS style three methods and the style of precedence 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.