[attribute], attribute exist - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:attribute exist

Description

The [attribute] selector selects elements with the specified attribute.

Example

Style all <a> elements with a target attribute:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
a[target] {<!--from  w  ww.  j a va2  s.c  o m-->
    background-color: yellow;
}
</style>
</head>
<body>

<p>The links with a target attribute 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>

</body>
</html>

Related Tutorials