Another specialty selector is the ID selector.
另一种特殊选择符是ID选择符。
Like the class, an ID selector is based on the value of an attribute, but in this case, it's the ID attribute.
与类选择符相似,ID选择符也基于一个属性的值,但这个属性是ID属性。
A simple selector is either a type selector or universal selector followed immediately by zero or more attribute selectors, ID selectors, or pseudo-classes, in any order.
一个简单选择符或者是一个类型选择符,或者是一个全局选择符,紧跟在后的是零个或多个属性选择符,ID选择符或伪类,次序任意。
We use id attributes mainly for layout and class attributes, for repeated elements, or elements we know will be hard to identify using a CSS selector.
对于布局,我们主要使用ID属性;对于重复的元素或者使用CSS选择器难以识别出的元素,使用class属性。
ID can be used on page only once, so we cannot make any reusable styles with an ID in selector.
ID在一个页面总只能出现一次,所以我们无法用ID选择器创造可重用的样式。
ID can be used on page only once, so we cannot make any reusable styles with an ID in selector.
ID在一个页面总只能出现一次,所以我们无法用ID选择器创造可重用的样式。
应用推荐