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


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>
<head lang='en'>
    <meta charset='UTF-8'>
        textarea[name='comment'] {
            border: 2px solid navy;
Name: <input type='text' name='name'>
Phone: <input type='text' name='phone'>

<textarea name='comment' rows='3'></textarea>

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] >>