Use quote marks to find an "exact phrase"

Print version

print icon

15: Selecting by element type

Selecting all instances of an element

In a previous lesson you learnt about two of the most common selectors: Classes and IDs. Here you will learn about another common way to select elements – selecting all instances of an element. If you want to select all paragraphs, or all images or all whatever, then this is it.

For selecting all instances of an element, the selector is simply the name of the element, as used in the code. In some cases, the name is the type of element spelled out in full (e.g. footer); others are abbreviated (e.g. div or p).

	
elementname		[selects all elements of that type]
		
p			[selects all paragraphs]		
		
footer			[selects all footers]
		

Looks simple doesn't it? And for once it really is.

How it looks in the stylesheet

Now (referring to the ruleset in a previous lesson), here are some examples to how they look in the stylesheet.

	
p {			[ruleset for all paragraphs]
  property: value;			
  property: value;			 
  }	
				

img {			[ruleset for all images]
  property: value;			
  property: value;			 
  }	


section {		[ruleset for all sections]
  property: value;			
  property: value;			 
  }		


footer {		[ruleset for all footers]
  property: value;			
  property: value;			 
  }	


header {		[ruleset for all headers]
  property: value;			
  property: value;			 
  }		
			

In the next lesson you will learn how to combine this type of selector with classes and IDs.