In CSS, can we select any HTML element by using it’s tag name as demonstrated in this exercise? Could I even create selectors to target HTML elements in the head of a document? For example, can I change the color of tab text with a title tag selector?
Answer
No. CSS is used to style our pages. As <head> tag content is not visible on the page itself, we can not target this metadata with tag selectors.
Whilst I’m only just learning CSS (and am relearning HTML as I haven’t done any in some time), as far as I know, you can’t style the tab text. It’s always uniform in all the browsers I use. You can add the little icon (don’t ask me how - been years since I last did it; hoping will learn again somewhere down the line!) but that’s about it.
Anyone with more knowledge, feel free to correct me if I’m wrong.
The icon you are talking about is called a “favicon”: https://en.wikipedia.org/wiki/Favicon .
You can add either of the following link elements in the of your html file. You have a lot of other info on the wikipedia article, including file formats, size, etc.
How do you know how to target specific paragraphs. For example, in this exercise, you style the first paragraph and the first header. How can you choose which specific paragraph in your HTML doc to style?
I don’t know if you’re referring to the fact that the other paragraphs weren’t styled. If you read the HTML code you will see that only the first and very last paragraphs are a p element, the rest are div elements, which is why they weren’t affected by the changes in the CSS doc. So to style each paragraph differently, you would have to asign a unique id/class.