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

[CSS Notes 2] Basic knowledge of CSS styles

黄舟
Release: 2016-12-29 13:46:54
Original
1397 people have browsed it

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>
Copy after login

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">
Copy after login

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>
Copy after login

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 tags. For example, the following code sets the text in all tags to red:

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

The embedded css style must be written between , and in general The embedded css style is written between .
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 tag within the (not within the