Three styles of CSS: inline, inline, external, and their priority

Source: Internet
Author: User

In the form of CSS-style code insertion, the basic can be divided into the following 3 kinds: inline, embedded and external three kinds.

1:内联式CSS style sheet is to write CSS code directly in the existing HTML tags, such as the following code:

<p style= "color:red";font-size:12px> here the text is red. </p>
2: Embedded, embedded CSS style. is the ability to write CSS style code in <style type= "Text/css" >XXX</style>Between the tabs.

3: External CSS style, written in a separate file.

An external CSS style (also known as an inline) is to write the CSS code in a separate external file, with the CSS style file " .css " as the extension. Use the <link> tag within

<link href="base.css" rel="stylesheet" type="text/css" />

Attention:

1. CSS style filenames are named with meaningful English letters, such as MAIN.CSS.

2, rel= "stylesheet" type= "text/css" is fixed notation can not be changed.

3, <link> label location is generally written in the

These three styles are prioritized, remembering their priorities:内联式 > 嵌入式 > 外部式。 ButEmbedded>external TypeThere is a premise that the placement of the embedded CSS style must be behind the exterior.


In fact, in conclusion, it is --就近原则(离被设置元素越近优先级别越高) .

But note that the precedence summarized above is a precondition: inline, inline, external style sheet CSS style is in theSame Weight valueThe case.


Three styles of CSS: inline, inline, external, and their priority

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.