Home  >  Article  >  Web Front-end  >  [CSS Notes 2] Basic knowledge of CSS styles

[CSS Notes 2] Basic knowledge of CSS styles

黄舟
黄舟Original
2016-12-29 13:46:541381browse

1. Inline CSS styles, written directly in existing HTML tags
Where can CSS styles be written? From the perspective of the form of CSS style code insertion, it can be basically divided into the following three types: inline, embedded and external.

The inline css style sheet is to write the css code directly in the existing HTML tag, such as the following code:

<p style="color:red">这里文字是红色。</p>

Be careful to write it in the start tag of the element, like the following The writing method is wrong:

<p>这里文字是红色。</p style="color:red">

and the css style code must be written in double quotes. If there are multiple css style code settings, they can be written together and separated by semicolons. The following code:

<p style="color:red;font-size:12px">这里文字是红色。</p>

2. Embedded css style, written in the current file
Inline styles can only be modified one by one, while embedded styles can set multiple text styles at one time.
Embedded css style means that the css style code can be written between the 080b747a20f9163200dd0a7d304ba388531ac245ce3e4fe3d50054a55f265927 tags. For example, the following code sets the text in all 45a2772a6b6107b401db3c9b82c049c2 tags to red:

<style type="text/css"> span{ color:red; } </style>

The embedded css style must be written between c9ccee2e6ea535a969eb3f532ad9fe89531ac245ce3e4fe3d50054a55f265927, and in general The embedded css style is written between 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1.
3. External css style, written in a separate file
External css style (also called external style) is to write the css code in a separate external file. This css style file starts with ".css" is the extension. Use the 2cdf5bf648cf2f33323966d7f58a7f3f tag within the 93f0f5c25f18dab9d176bd4f6de5d30e (not within the c9ccee2e6ea535a969eb3f532ad9fe89 tag) to link the css style file to the HTML file, as shown in the following code:

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

Note:

css style file names are named with meaningful English letters, such as main.css.

rel=”stylesheet” type=”text/css” is a fixed writing method that cannot be modified.
The rel attribute is used to define the relationship between the linked file and the HTML document. Stylesheet means style call. The position of the

2cdf5bf648cf2f33323966d7f58a7f3f tag is generally written within the 93f0f5c25f18dab9d176bd4f6de5d30e tag.

4. Priority of the three styles

Under the same weight, the inline style has the highest priority. Embedded and external
are divided according to the proximity principle (the closer to the element being set, the higher the priority).

The above is the content of [CSS Notes 2] basic knowledge of CSS styles. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:position usage in cssNext article:position usage in css