Methods to put css in html files: 1. Add CSS directly to the style attribute in the HTML tag; 2. Write CSS under the style tag in the HTML header; 3. Use the head tag to introduce external CSS files; 4. Use CSS rules to introduce external CSS files.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, DELL G3 computer
How to introduce CSS into HTML
There are 4 ways to introduce CSS in HTML. Two of them are to add CSS code directly in the HTML file, and the other two are to introduce external CSS files. Let’s take a look at these methods and their advantages and disadvantages.
Inline method
The inline method refers to adding CSS directly to the style attribute in the HTML tag.
Example:
<div style="background: red"></div>
This is usually a bad way of writing, it can only change the style of the current tag. If you want multiple
Embedding method
The embedding method refers to writing CSS code under the