Home >Web Front-end >HTML Tutorial >How HTML uses CSS
With HTML4.0, all formatting code can be moved out of the HTML document and into a separate style sheet (.css).
How to use styles(Recommended learning: HTML introductory tutorial)
When the browser After reading a style sheet, it will format the document according to the style sheet. There are three ways to insert a style sheet:
External style sheet
When styles need to be applied to many pages, an external style sheet will be ideal choice. Using external style sheets, you can change the appearance of the entire site by changing one file.
<head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head>
Internal style sheet
When a single file requires special styling, you can use an internal style sheet. You can define internal style sheets via the c9ccee2e6ea535a969eb3f532ad9fe89 tag in the head section.
<head> <style type="text/css"> body {background-color: red} p {margin-left: 20px} </style> </head>
Inline styles
Inline styles can be used when special styles need to be applied to individual elements. The way to use inline styles is to use the style attribute in the relevant tag. Style properties can contain any CSS property. The following example shows how to change the color and left margin of a paragraph.
<p style="color: red; margin-left: 20px"> This is a paragraph </p>
The above is the detailed content of How HTML uses CSS. For more information, please follow other related articles on the PHP Chinese website!