Structural Pseudo-Classes
Pseudos:
Pseudo | Support | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
:empty |
|
Applies to elements that do not have any content. | ||||||||||
:first-child | Applies to any element that is the first child of its parent. | |||||||||||
:first-of-type |
|
Applies to any element that is the first child of its type in its parent. | ||||||||||
:last-child |
|
Applies to any element that is the last child of its parent. | ||||||||||
:last-of-type |
|
Applies to any element that is the last child of its type in its parent. | ||||||||||
:nth-child () |
|
Applies to any element that is the n-th child of its parent. | ||||||||||
:nth-last-child () |
|
Applies to any element that is the n-th child of its parent, counting from the last one. | ||||||||||
:nth-of-type () |
|
Applies to any element that is the n-th sibling of its type. | ||||||||||
:nth-last-of-type () |
|
Applies to any element that is the n-th sibling of its type, counting from the last one. | ||||||||||
:only-child |
|
Applies to any element that is the only child of its parent. | ||||||||||
:only-of-type |
|
Applies to any element that is the only sibling of its type. | ||||||||||
:root |
|
Applies to the top-level element of a document. |
:empty
Applies to elements that do not have any content.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:first-child
Applies to any element that is the first child of its parent.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:first-of-type
Applies to any element that is the first child of its type in its parent.
Note: The :first-of-type pseudo is supported in Firefox from version 3.5.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:last-child
Applies to any element that is the last child of its parent.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:last-of-type
Applies to any element that is the last child of its type in its parent.
Note: The :last-of-type pseudo is supported in Firefox from version 3.5.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:nth-child (selector)
Applies to any element that is the n-th child of its parent.
Note: The :nth-child pseudo is supported in Firefox from version 3.5.
The selector specifies the position of the element or elements in the childNodes collection that the style rules applies to.
It can be an integer, a string ('even' or 'odd'), or an expression, such as 2n+1.
Possible values:
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:nth-last-child (selector)
Applies to any element that is the n-th child of its parent, counting from the last one.
Note: The :nth-last-child pseudo is supported in Firefox from version 3.5.
The selector specifies the position of the child or children relative to the last one that the style rules applies to.
It can be an integer, a string ('even' or 'odd'), or an expression, such as 2n+1.
Possible values:
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:nth-of-type (selector)
Applies to any element that is the n-th sibling of its type.
Note: The :nth-of-type pseudo is supported in Firefox from version 3.5.
The selector specifies the position of the child or children of the specified type that the style rules applies to.
It can be an integer, a string ('even' or 'odd'), or an expression, such as 2n+1.
Possible values:
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:nth-last-of-type (selector)
Applies to any element that is the n-th sibling of its type, counting from the last one.
Note: The :nth-last-of-type pseudo is supported in Firefox from version 3.5.
The selector specifies the position of the child or children of the specified type relative to the last one that the style rules applies to.
It can be an integer, a string ('even' or 'odd'), or an expression, such as 2n+1.
Possible values:
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:only-child
Applies to any element that is the only child of its parent.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:only-of-type
Applies to any element that is the only sibling of its type.
Note: The :only-of-type pseudo is supported in Firefox from version 3.5.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
||||||||||||||||||||||||||
:root
Applies to the top-level element of a document. In a HTML document, this is the HTML element.
Supported by tags:a, abbr, acronym, address, applet, b, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, H1, H2, H3, H4, H5, H6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, object, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tt, u, ul, var, xmp
|
User Contributed Comments