What are the three ways of using css style sheets?

青灯夜游
Release: 2021-01-18 10:12:06
Original
31235 people have browsed it

The three methods are: 1. Inline style sheet, using the style attribute to directly add CSS code to the HTML markup. 2. In the internal style sheet, write the css style in the "

" tag and declare it with the "

The operating environment of this article: Acer S40-51, HBuilderX.3.0.5&&css3 version, Windows10 Home Chinese version

(Learning video sharing: css video tutorial)

There are three ways to use css style sheets:

  • Inline style sheets

  • Internal style sheets

  • External style sheet

Inline style sheet

Inline style is Use the style attribute to directly add CSS code to the HTML tag, that is, it exists as an attribute tag of the HTML tag.

Example:

<h1 style="color:red;">style属性的应用</h1>
Copy after login

With this method, you can easily define the style of an element individually.

Example:

What are the three ways of using css style sheets?

Advantages and disadvantages of inline style sheets:

Advantages:

  • Without the style sheet file, efficiency can be improved at some point;

  • The style effect using the style attribute will be the strongest and will overwrite Remove the same style effect from other introduction methods.

Disadvantages:

  • It is difficult to share styles with multiple elements, which is not conducive to code reuse;

  • HTML and CSS code are mixed, making it difficult for programmers and search engines to read.

##Internal style sheet

The internal style sheet writes the css style in the tag and uses