HTML and CSS Reference
In-Depth Information
So, if we apply this selector to the following HTML:
<p>Paragraph example.</p>
<p>Paragraph example.</p>
<p>Paragraph example.</p>
<div class="box">
<p>Paragraph example.</p>
<p>Paragraph example.</p>
...the styles will apply only to the second, third, and fifth paragraphs in this section of HTML.
Attribute Selector
The attribute selector targets elements based on the presence and/or value of HTML attrib-
utes, and is declared using square brackets:
input[type="text"] {
background-color: #444;
width: 200px;
There should not be a space before the opening square bracket unless you intend to use it
along with a descendant combinator. The above CSS would match the following element:
<input type="text">
But it wouldn't match this one:
<input type="submit">
The attribute selector can also be declared using just the attribute itself, with no value, like
Search WWH ::

Custom Search