CSS ID selectors & wild selector

ID selector

ID (IDentity) is the number of means, generally designated unique number tag in the HTML document. ID tag selector and selector, different scope class selector.
ID selector only define a style of the object, and the tag class selector and selector may define a plurality of style objects.
ID # to the selector as a prefix number, then a self-ID name is defined, as shown in FIG usage

example:

<!doctype html>
<html>
<head>
    <style type="text/css">
        #box{/*ID样式*/
        background: url("../photos/野外.jpg")center bottom;
            height: 200px;
            width: 400px;
            border: solid 2px red;
            padding: 100px;
            }
    </style>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
    <div id="box">问君能有几多愁,恰似一江春水向东流</div>
</body>
</html>

The results:

In addition, the range can also be specified tag ID selector. Definition specifies the ID selector mechanism as shown in the syntax:

With this method may increase the priority of the style.

Wild selector ##

So if HTML elements needed given the same meaning style, then one by one they were defined styles, will feel very troublesome. This trouble can be solved by using the wildcard selector.
The selector system with a fixed, using the "*" represents, for example:

<!DOCTYPE html>
<html>
    <head>  
        <meta charset="utf-8">
        <title>通配符选择器(理解)</title>
        <base target="_self">
        <style>
            *{
                color: red;
                }
        </style>
    </head>
    <body>
        <h1>我是标题</h1>
        <p>我是段落</p>
        <a href="#">我是超链接</a>
    </body>
</html>

Guess you like

Origin www.cnblogs.com/kangna/p/11922765.html