HTML and CSS Reference
In-Depth Information
The following form contains one required and one optional input element, which is
targeted by the previous styles:
<form>
<input type="email" required>
<input type="url">
</form>
Like the
:valid
and
:invalid
pseudo-classes, support for
:required
and
:optional
is limited to Chrome 10+, Firefox 4+, IE10+, Safari 5+, and Opera 10+.
Other pseudo-classes
Some pseudo-classes do not fit into any of the earlier categories, namely the
:target
,
:lang
, and
:not
pseudo-classes.
target
The
:target
pseudo-class can style an element that is targeted through an
id
link. It can
be useful for highlighting a targeted section of the document.
:target { font-weight: bold; } /* targeted element */
When the following internal page link is followed, this rule is applied to the anchor
element. The browser also scrolls down to that element.
<a href="#my-target" id="my-target">In page link</a>
This pseudo-class is supported in all major browsers, except IE8 and earlier
versions.
lang
The pseudo-class
:lang()
matches elements determined to be in the language provided
by the argument.
p:lang(en) {}
This pseudo-class applies to paragraph elements that are intended for an English
audience, such as the following paragraph:
<p lang="en">English</p>