1. Internal style
Internal style is also called inline style. Use style tag to write css code in head tag.
to sum up:
- In the grammar, the style tag is usually located after the title tag in the head tag, and it can also be placed anywhere in the HTML document.
- type="text/CSS" can be omitted in html5, and it is more in line with the specification, so this place can be written or omitted.
2. In-line style
Set the style directly on the label by using style="attribute:value".
3. External style
In this way, you need to create a separate css file, write all the css code into the file, and then use the link tag to import it in the html file.
- href: Defines the URL of the linked external style sheet file, which can be a relative path or an absolute path.
- rel: Define the relationship between the current document and the linked document, where it needs to be specified as "stylesheet", which means that the linked document is a style sheet file.
Comparison between the three methods