Three ways to use css styles

What is css: css is a cascading style tag, which is used to format web pages! There are three ways to introduce css files into html files, as follows:

csss attribute writing method: tag name { attribute name: attribute value;

                                         Attribute name: attribute value;

                                                }

1. Inline (inline) style, written in the start tag, used through the style attribute name

<div style="color:red; height=100;">
    测试文字
</div>
行内样式,写在style的""里,两个属性之间用空格隔开,属性值用分号隔开。

2. Head style, written in the head tag <head></head> and used through the <style></style> tag

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单</title>
    <style>
        p{
           color:red;
            }
    </style>
</head>

3. External style,  written in the head <head> tag through <link href="file address" >

<link rel="stylesheet" href="css文件位置">

4. The method provided by @import css is to load the html file first and then load the css. It is not compatible with IE5 or below.

Guess you like

Origin blog.csdn.net/weixin_51828648/article/details/126969080