Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. [CSS Selector] E > F

[CSS Selector] E > F

Using '>' applies styles only to direct child elements of the specified element.

Sample Code

style.css
/* Apply only to direct child divs of .hoge (grandchildren are excluded) */
div.hoge > div { color: red;}
div { color: blue;}

/* Apply only to li elements that are direct children of ul (nested li excluded) */
ul > li { list-style-type: disc;}

/* Apply only to a elements directly inside nav */
nav > a { font-weight: bold;}

/* Apply only to input elements that are direct children of form */
form > input { border: 1px solid #ccc;}

/* Difference between child combinator (>) and descendant combinator (space) */
.parent > .child { color: red;} /* direct children only */
.parent .child { color: blue;} /* all descendants */

Browser Display Result

div.hoge > div { color: red;} /* Applies only to elements that are direct children of a div element with the class name 'hoge'. */
div { color: blue;}

<div class="hoge">
	<div>This is a div element inside a div element with the class name 'hoge'.</div>
	<div>
		<div>This is a div element inside a div element inside a div element with the class name 'hoge'. Since it is not a direct child of 'div.hoge', the text color does not become red.</div>
	</div>
</div>

Browser Compatibility

Chrome Chrome
1+
Firefox Firefox
1+
Safari Safari
1+
Edge Edge
12+
IE IE
11
10
9
8
7
6 ×
Opera Opera
4+
3 and earlier ×
iOS Safari iOS Safari
1+
Android Android Browser
4.4+
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop
Firefox Android Firefox Android
Latest
Same support as desktop

※ Version data is based on MDN.

If you find any errors or copyright issues, please .