What does the . mean in CSS?
I've read several tutorials on CSS, but none of the sites I've looked at 开发者_StackOverflowmentions or explains what a "." means in CSS.
What does the . mean?
Nothing without context.
I'll hazard a guess that you are referring to a class selector.
Well, in the following context:
.foo {
//properties
}
it indicates that foo is a class. A # means it's an id and if it has nothing it means that it is for all tags of that type. So, in html, you would implement something with a "." like this:
<div class = "foo"></div>
For a "#" it would be
<div id = "foo"></div>
Use class/"." if you want to apply it to more than one thing. Use id/"#" if you want it to apply to one thing.
Ok, so if your wondering what a class is: A class is one of the three (I think it's 3) types of ways you select stuff in css. The id (which I explained) says that the following properties apply to anything (usually one thing) with 'id="foo"' in its tag. A class selector means that it applies to everything with a "class="foo"" in its tag. If it has none of these than it means that it applies to all things with that name.
.foo { //applies to all things with "class="foo"" in tag.
border: black thin solid // applies a black border to them.
}
#foo { //applies to all things with "id="foo"" in tag.
border: black thin solid // applies a black border to them.
}
div{ //applies to all div tags.
border: black thin solid // applies a black border to them.
}
h1{ //applies to all h1 tags
border: black thin solid // applies a black border to them.
}
It is a class selector. Means the rule should be applied to all elements that have an attribute class
with the value after the .
.
精彩评论