Attribute Selector
We’ve added a footer to the bottom of the page, with a link to the source of our text and a link back to the top of the page. The first link opens in a new tab, because it has the attribute target="_blank":
<footer>
<p>Source: <a href="https://en.wikipedia.org/wiki/Cat" target="_blank">Wikipedia</a></p>
<p><a href="#title">Back to top</a></p>
</footer>Elements can also be selected by their attributes. An attribute selector is written in square brackets:
[target]selects the elements that have the attributetarget, whatever its value,[target="_blank"]selects the elements whose attributetargethas exactly the value_blank.
You can write a type selector right before the brackets: a[target="_blank"] selects the a elements with the attribute target="_blank", that is, the links that open in a new tab. It’s good to let visitors know about such links, so let’s make them look different.
Instructions
- 1
Create a rule for
a[target="_blank"]that sets italics:font-style: italic. The link to Wikipedia will be in italics, while the link back to the top stays as it is.