Select <a> elements with a target="_blank": - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:attribute equals value

Description

Select <a> elements with a target="_blank":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
a[target=_blank] {
    background-color: yellow;
}
</style><!--from w w w . j  a  v a2s  .  c  om-->
</head>
<body>

<p>The link with target="_blank" gets a yellow background:</p>

<a href="https://www.java2s.com">java2s.com</a>
<a href="http://www.google.com" target="_blank">google.com</a>
<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a>

<p><b>Note:</b> For [<i>attribute</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p>

</body>
</html>

Related Tutorials