What are the methods of introducing css style sheets?

青灯夜游
Release: 2021-06-08 14:33:35
Original
5412 people have browsed it

Method: 1. Add CSS style to the style attribute in the element tag; 2. Add CSS style to the style tag pair in the head part of the document; 3. Put the CSS code into the ".css" file , imported using the "" statement.

What are the methods of introducing css style sheets?

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Three Style Sheets of CSS

According to the position where the CSS style is written (or the way it is introduced), CSS style sheets can be divided into the following three categories:

  • Inline style sheet (inline)

  • Internal style sheet (embedded)

  • External style Table (linked)

1. Inline style sheet

The syntax format of the inline style sheet is as follows:

<div style="color: blue; font-size: 16px;">测试</div>
Copy after login

Note:

  • Inline style sheets set CSS styles in the style attribute inside the element tag, and are only suitable for modifying simple styles

2. Internal style sheet

The syntax format of the internal style sheet is as follows:

<style>
div {
color: blue;
font-size: 16px;
}
</style>
Copy after login

Note:

  • Internal style The table extracts all the CSS code and puts it in a