Home Web Front-end Front-end Q&A What are the three ways to implement css in html?

What are the three ways to implement css in html?

Apr 07, 2021 am 11:26 AM
css html

Three implementation methods: 1. Use the style attribute in the html tag to define the css style; 2. Write the css style in the "" tag in the header of the html file; 3. , introduce external CSS style files through the "" tag.

What are the three ways to implement css in html?

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

CSS styles are referenced in 3 ways. They are defined inline, linked to internal CSS and linked to external CSS.

1. Inline definition

Inline definition, that is, using the object's style attribute within the object's tag to define the applicable style sheet attributes. The format is defined as: <p style="content"></p>, the following example


The browser displays the content at this time


2. Link to internal CSS

The link within CSS is made by <style></style> The tag pair is placed in <head></head>. There is a type attribute type in