3. Base Selector
HTML Tag Selector
通过html标签名来选择元素① 所有的html标签都可以当做选择器② 无论标签藏多深都会被选中③ 选择的是所有的标签而不是具体某个标签。所以说我们通过html标签选择器来设置的都是一些共性问题。
ID Selector
① 任何的标签都可以有id属性和属性值(因为id是一个全局属性)。id命名不能随意的命名。大小写敏感 ,id的名字中可以有数字字母下划线,但是要以字母开头。 驼峰命名法 小驼峰命名 大驼峰命名 testHeader 小驼峰 TestHeader 大驼峰
Class Selector
① 任何的标签都可以使用class属性(class属性也是一个全局属性) ② class属性名可以重复使用 ③ 一个class属性中,可以有多个class属性值。
=======================
Second, integrated selector
- Descendant selector Div p
- Intersection selector DIV.D1
- Set Selector div,p
- Child element Selector Div>p
- Sequence Selector ul Li:first-child Ul:li:last-child
- Neighboring brother selector Div + P
- Ordinary brother selector Div ~ P
Third, inheritance and Cascade 1. Inherited
Some CSS properties of the parent element will inherit the past with the quilt element unconditionally. CSS properties on text can be inherited:color text- line- font-
2. Cascade
Cascading solves the problem of CSS conflicts.
Compare weights to solve cascading problems.
!important can change the weight of the "individual attribute" to infinity. Use as little as possible.
Block-level elements and inline elements
divBlock-level elements
spanIn-line elements
The difference between a block-level element and an in-line element:
1. 行内元素部不能够设置宽度和高度。行内元素的宽度和高度是标签内容的宽度和高度。块级元素可以设置宽度和高度。2. 块级元素会独占一行。而行内元素却部能够独占一行,只能和其他的行内元素共用一行。3. 如果块级元素不设置宽度,那么块级元素会自动的沾满父元素的全部宽度。
Conversion between block-level elements and inline elements
Display:inline Block Inlin-block
HTML Note 3