Home > Web Front-end > CSS Tutorial > Why does list-style:none in css not work?

Why does list-style:none in css not work?

黄舟
Release: 2017-06-29 09:29:10
Original
4624 people have browsed it

See the code below? Why doesn't list-style:none work?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<title>无标题文档</title>
<style type="text/css">
    body{
        list-style:none;
    }
</style>
 
</head>
 
<body>
    <ul>
        <li>
            aaaaaa
        </li>
        <li>
            bbbbbb
        </li>
    </ul>
</body>
</html>
Copy after login

The default level of ul is not as high.

Why should it be set on the body?

If you set it on the body, then the subsequent ul will inherit the settings of this body. The inherited things will be overwritten by the properties carried by itself. of.

What a complicated question~
Can you understand it this way:
The default style of ul belongs to the inline style sheet
The body{...} in the head tag belongs to the internal style sheet
And the priority of the internal style sheet is lower than that of the inline style sheet

If it is not reflected, it is best to add it to the css style in the div, which is the most stable

Written on the body, it can theoretically be inherited by elements in the body, but the permissions inherited in CSS are the lowest, so it will be overwritten by UL's own default style. Such code is generally written directly to UL

ul{
        list-style:none;
    }
Copy after login

The above is the detailed content of Why does list-style:none in css not work?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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