What is the difference between css selector pound sign and period?

零下一度
Release: 2017-06-28 09:51:00
Original
2383 people have browsed it
CSS里的样式表是有规则组成的,每条规则有三个部分组成:
1、选择器(如下面例子中的:“body”),告诉浏览器文档的哪个部分受规则影响;
2、属性(如实例中的font-family、color等),规定了布局的什么方面被设置了;
3、值(如实例中的Arial,sans-serif,#333333等),给出了式样属性的值。
 #是ID选择器 .是class选择器 *是通配符号 
比如*{margin:0;padding:0;所有的元素都会沿用这个属性样式}(还有一种情况是IE hack)比如 .b{margin:0;*margin:10px;}这里IE看到的是margin:10px,其他的浏览器看到的会是前面那个margin:0;
Copy after login

Let’s look at the code first~

body{
font-family: Arial,sans-serif;
color: #333333;
line-height: 1.166; 
margin: 0px;
 padding: 0px;
}
#masthead{
margin: 0;
padding: 10px 0px;
border-bottom: 1px solid #cccccc;
width: 100%;
}
.feature img{
float: left;
padding: 0px 10px 0px 0px;
 margin: 0 5px 5px 0;
}
Copy after login


# corresponds to the id
The dot corresponds to class
No corresponding html tags
It can be summed up in one sentence: Class can be used repeatedly but ID can only be used once in a page. It's possible that using the same ID repeatedly will not cause problems in a large number of browsers, but this is definitely an incorrect use according to the standard, and may cause real-life problems in some browsers.
In actual application, Class may be more useful for text layout, etc., while ID is more useful for macro layout and design placement of various elements.


The above is the detailed content of What is the difference between css selector pound sign and period?. 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