Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between . and # in a css file?

Tags:

syntax

css

In css examples, I've seen rules defined starting with a . and some starting with # - sometimes these are mixed in the same file. What is the difference between these rules:

h1  { font-size:18pt;} .new-alerts  { font-size:11pt; font-weight:bold;} #old-alerts  { position:relative; font-size:10pt; } 

Are they referenced differently on the html page? Is it how the properties are inherited?

like image 814
George Avatar asked Feb 11 '10 16:02

George


People also ask

What's the difference between () and []?

() is a tuple: An immutable collection of values, usually (but not necessarily) of different types. [] is a list: A mutable collection of values, usually (but not necessarily) of the same type.

What's the difference between and and and?

In general, using & implies a much more informal tone than and. You will never be criticized for using and, whereas you run the risk of disapproval if you use & in anything but informal notes, tweets and the like. "&" is also often used in company names or titles, i.e. Barnes & Noble.

What is the difference between '/' and '/' in Python?

There is no difference at runtime. The only difference between the two types of quotes is the one you have already pointed out: Single quotes need to be escaped inside single quoted string literals but not inside double-quoted string literals.

What is the difference between 3 and 5?

if we are told to find the difference between 3 and 5, then we usually subtract 3 from 5 ,5-3=2 and thus, we say that the difference is 2.


1 Answers

. refers to a class. <span class="one" /> could be selected with .one.

# refers to an ID. <span id="one" /> could be selected with #one.

You should be using classes when there could be more than one of a given element, and IDs when you know there will only be one. #navigation-bar would be using an ID because you will only have one navigation bar in your layout, but .navigation-link would be using a class name because you will have multiple navigation links. (It'd be better practice to use #navigation-bar a:link to get the navigation links, but you get my point.)

like image 191
Matchu Avatar answered Sep 29 '22 14:09

Matchu