CSS3 Selectors: An element that has an attribute with a value E[attr=val]

This entry is part 12 of 40 in the series CSS3 Selectors

E[attr=val]

Matches any element E that has the attribute attr with any value.

We use textarea[name=’comment’] as an example.  This will match the element to a multiline textbox.

<!DOCTYPE html>
<html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com-Form</title>
    <style>
        textarea[name='comment'] {
            border: 2px solid navy;
        }
    </style>
</head>
<body>
<br>
Name: <input type='text' name='name'>
<br>
Phone: <input type='text' name='phone'>
<br>

Comments:
<br>
<textarea name='comment' rows='3'></textarea>
</body>
</html>

If we use another attribute textarea[rows=’3′], it will still work.

Series Navigation<< CSS3 Selectors: An element with an attribute E[attr]
CSS3 Selectors: Hyphen separated list of values E[attr|=val] >>