Jun 3, 2015

CSS Selectors


The CSS selectors are the way to access and change the HTML elements visual aspects, like color, position, size, font etc. Here you can see how use them.

You can access any HTML element using one of these selectors:

Element

ptag {
    color: blue;
    text-align: center;
} 

Id

#pid {
    color: blue;
    text-align: center;
} 

Class

.pclass{
    color: blue;
    text-align: center;
} 

Element Class

pelement.pclass{
  color: blue;  
  text-align: center;
} 

Element Id

pelement#pid{
  color: blue;  
  text-align: center;
} 

And if you have the same CSS for two or more elements, you can group them:

p, h1, h2 {
    color: blue;
    text-align: center;
}

This are the CSS version 1 and 2 basic selectors, a full list including CSS 3 selectors, can be found here.

0 comentários :

Post a Comment