Web Front end--html Basic Note No.7

Source: Internet
Author: User

Where can CSS styles be written? From the form of CSS style code insertion, the basic can be divided into the following 3 kinds: inline, embedded and external three kinds of inline CSS style, directly written in the existing HTML tags

内联式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 word is red </p>

CSS style code to write in style= "" double quotes, if there are multiple CSS style code settings can be written together, separated by semicolons.

Embedded CSS style, written in the current file

The embedded CSS style is the ability to write CSS style code between <style type= "text/css" ></style> tags. The following code is implemented to set the text in three <span> tags to red:

<type= "Text/css">span{color:  Red; }</style>

Embedded CSS styles must be written between <style></style>, and in general the embedded CSS style is written between

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, within

<href= "Base.css"  rel= "stylesheet"  type= "text/ CSS "/>

Attention:

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

2, rel= "stylesheet" type= "text/css" is fixed notation cannot be modified.

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

Three ways to prioritize

1. Use 内联式 CSS to set "super cool Internet" text for 粉色 .

2. Then use 嵌入式 CSS to set the text to 红色 .

3, and finally use 外部式 the settings text 蓝色 (style.css file Settings).

But eventually you can observe that the text of the short word "super cool Internet" is set in order 粉色 . Because these three styles are prioritized, remember their priorities:

inline > Embedded > External

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

Web Front end--html Basic Note No.7

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.