Apply styling to immediate children only in CSS

In CSS you can apply styling to all children of a selector to an unlimited depth using a space, as demonstrated below where all list items inside the 'nav' class would have the applied border styling:

.nav li
{
    border:1px solid #000;
}

If you only want to affect immediate children however (for example, if you had sub menus within the list items) then you can use greater than arrow instead:

.nav > li
{
    border:1px solid #000;
}

 

Sign Up
comments powered by Disqus
Sign Up

Popular Tags

350x250

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.