Home > Web Front-end > CSS Tutorial > What are the three ways to write CSS styles?

What are the three ways to write CSS styles?

王林
Release: 2020-08-24 16:17:08
forward
5492 people have browsed it

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>
Copy after login

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>
Copy after login

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">
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template