HelloWord]."/> HelloWord].">
Home > Article > Web Front-end > What are the three ways to write CSS styles?
Three ways to write css styles:
(Recommended tutorial: CSS tutorial)
1. Inline style
sets the style of the element through the style attribute of the tag. The basic syntax format is as follows:
<span style="color:#000;font-size:16px">HelloWord</span>
In the syntax, style is the attribute of the tag. In fact, any HTML tag has the style attribute, which is used to Set the inline style, in which the writing specifications of the attribute values are the same as the CSS style rules. The inline style affects all its tags and the subtags nested in them.
2. Internal style sheet
Embedded style is to write the css code in the head tag of the HTML document and define it with the style tag. Its basic syntax format is as follows:
<head> <style> p {color: #000;font-size: 16px} </style> </head>
In syntax, the style tag is generally located after the head tag, but it can also be placed anywhere in the HTML document.
3. External link style
The link-in style is to place all styles in one or more external style sheet files with CSS as the extension, and link the external styles through the link tag into an HTML document, its basic syntax format is as follows:
<link href="Test.css" type="text/css" rel="stylesheet">
The above is the detailed content of What are the three ways to write CSS styles?. For more information, please follow other related articles on the PHP Chinese website!