Sei sulla pagina 1di 1

 

CSS Selectors 
You've now learned about three kind of CSS selectors: ​type​, c​ lass​, 
and ​ID​!   
 
 
● Type​ selectors are used to apply a style to a particular type of HTML element, like h
​ 1​ or 
body​.  
Type selectors are written using just the type name. 
 
● Class​ selectors are used to set the style for multiple HTML elements that have a particular 
value for the ​class​ attribute.  
You can name a class anything you want! Class selectors are written with a dot before the 
class: for elements such as < ​ p class="blue">​, the class selector is .
​ blue​. 
 
● ID​ selectors are used when the style is being applied to one HTML element, which has to 
have an ​id​ attribute.  
There can be only o ​ ne ​element with a particular i ​ d​ on a page. You can also choose any name 
you want for an ​id​, just like a​ ​class​. ID selectors are written using a #​ ​ sign: for an element 
such as <​ div id="sidebar">​, the ​id​ selector is # ​ sidebar​. 

 
version 1.0 

Potrebbero piacerti anche