In the example shown in this exercise wouldn’t it be easier to just apply the `color` and `font-weight` properties to the `h2` selector rather than applying two separate classes to the opening <h1> tag?


#1

Question

In the example shown in this exercise wouldn’t it be easier to just apply the color and font-weight properties to the h2 selector rather than applying two separate classes to the opening

tag?

Answer

The code snippet in this exercise is used purely for demonstrative purpose. That having been said, you are correct in that it sometimes does makes more sense to use a tag selector to target a whole group of elements as opposed to applying multiple classes to the elements we want to target.

There are numerous CSS organizational philosophies, but it is important to realize that if you were to use an h1 tag selector, your styles would get applied to all the <h1> elements in the HTML document. If you wanted certain <h1> elements to have different styling, you would need to overwrite any declarations you wanted to change within the h1 selector. This can be done by using a higher specificity selector. For example, given the <h1 class=”bold> … </h1> element, this selector

	font-weight: bold;
	}```

	Would overwrite this selector:
	
	```h1 {
		font-weight: normal.
}```

In this example, our `<h1>` elements with a class of `.bold` would get the bold font-weight styling. 

You will learn more about CSS specificity in exercise 11 so stay tuned!

FAQ: Learn CSS Selectors Visual Rules - CSS Setup Selectors - Multiple Classes