Содержание
CSS: child selector
This CSS tutorial explains how to use the CSS child selector with syntax and examples.
Description
The CSS child selector uses the > character to target an element that is a direct child of an element type.
Syntax
The syntax for the :active CSS selector is:
Parameters or Arguments
element1 The first element type to match. element2 The second element type to match that must be a direct child of element1. style_properties The CSS styles to apply to the targeted element2.
Note
- The child selector uses the > combinator to target an element that is a direct child of another element.
- See also the descendant selector.
Browser Compatibility
The CSS child selector has basic support with the following browsers:
- Chrome
- Firefox (Gecko)
- Internet Explorer 7+ (IE 7+)
- Opera
- Safari (WebKit)
Example
We will discuss the child selector below, exploring examples of how to use this selector in CSS.
The CSS would look like this:
The HTML would look like this:
- TechOnTheNet.com
- Oracle/PLSQL
- SQL
- Excel
- CheckYourMath.com
- BigActivities.com
- tag will be styled by the child selector (ie: styled with red font). So in the case of the three
tags under the
tag:
- tag and therefore are not styled by the child selector. If you wanted them to styled like the other
tags, you might want to try using the descendant selector.