How to grab a font-awesome icon in the li tag which is first-child

font awesome icons
font awesome css content
font awesome cdn
font awesome light
import font awesome icons
how to use font awesome icons
font awesome code
font awesome vector icons

The folders aaa bbb ccc and ddd are the main directories in this html structure. How can i disable (display;none) the font-awesome icon for the main directories only? For the main directories, the icon should not appear PS: I can not change the classname because its dynamically generated for all the li tags! This is my html:

<ul>
    <li class="treeview"><i class="fas fa-level-up-alt"></i>aaa</li>
    <li class="treeview"><i class="fas fa-level-up-alt"></i>bbb</li>
    <li class="treeview"><i class="fas fa-level-up-alt"></i>ccc
       <ul>
           <li class="treeview"><i class="fas fa-level-up-alt"></i>subccc</li>
       </ul>
    </li>
    <li class="treeview"><i class="fas fa-level-up-alt"></i>ddd
       <ul>
           <li class="treeview"><i class="fas fa-level-up-alt"></i>subddd</li>
       </ul>
    </li>
</ul>

What I would recommend doing is making use of the child combinator (>) to set display: none on the top level (ul > li > .fas) icons, and then also making use of CSS specificity to additionally add a more specific selector for elements lower down the hierarchy.

Although both selectors will actually target the child icons, because there's a more specific selector applied which sets the icons as visible again, these elements will show up.

This can be seen in the following:

ul > li > .fas {
  display: none;
}

ul li > ul .fas {
  display: inline-block;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet"/>

<ul>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>aaa</li>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>bbb</li>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>ccc
    <ul>
      <li class="treeview"><i class="fas fa-level-up-alt"></i>subccc</li>
    </ul>
  </li>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>ddd
    <ul>
      <li class="treeview"><i class="fas fa-level-up-alt"></i>subddd</li>
    </ul>
  </li>
</ul>

CSS Pseudo-Elements, Pre-order today and get a special price and early access to new icons, Save $20 off of the first year of your Font Awesome Pro subscription when you Cotton Bureau, who produces our shirts, provides fits for men, women, and children. Select and style every <i> element of every <p> element, where the <p> element is the first child of its parent:

You can consider 2 selectors to achieve this:

/*Hide all of them*/
ul li.treeview i {
  display: none;
}


/*Show the nested ones*/
ul ul li.treeview i {
  display: inline-block;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<ul>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>aaa</li>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>bbb</li>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>ccc
    <ul>
      <li class="treeview"><i class="fas fa-level-up-alt"></i>subccc</li>
    </ul>
  </li>
  <li class="treeview"><i class="fas fa-level-up-alt"></i>ddd
    <ul>
      <li class="treeview"><i class="fas fa-level-up-alt"></i>subddd</li>
    </ul>
  </li>
</ul>

icon in Font Awesome, The first child is the devil element (using the animation named rotate ) and the second child is the spin icon Import the icon font Font Awesome into your CSS: HTML Tag Reference HTML Browser Support HTML Event Font Awesome 4 Font Awesome Intro Icons Brand Icons Chart Icons Currency Icons fa fa-hand-grab-o: Try it:

This should do the trick : }

ul:first-child > li {
display:none;
}

Hope it helped !

5 Use Cases for Icon Fonts, First we will add the font awesome icons css in head section of html file as shown below <li> <span class="icons twitter"></span> Login </li> .twitter::before { font-​family: Font Awesome CDN is the best way to get Font Awesome on baby-​carriage, fa-baby-carriage, f77d user-tag, fa-user-tag, f507. The Blogger Label Gadget is not pretty. And tag clouds are old school. And ugly. Especially the default styles with the different sized fonts. It just ends up a big blog of words that your readers ignore.

Font Awesome Icons list & Font Awesome CSS content values , Apart from including the icons at build time, you can try a separate style tag in the head You may want to use Font Awesome icons without the icon element. In CSS, ::before creates a pseudo-element that is the first child of the selected element. CSS: Spacing of elements. pdf-download-icon li:before { content: "\​f1c1";  Vector Icons Roundup: a comparison between FontAwesome, Glyphicons, Foundation Icon Fonts, Material Design Icons, Ionicons and Elusive-Icons

Css before icon, Themify WordPress themes already come with both FontAwesome <ul> <li id="​menu-link-1"><a href="#">Home</a></li> <li you need to get an icon font to display: the icon's unicode number, First, we restyle the menu's default links: These icons are then referenced (using the tag) into inline SVG  Instead, I used a Base64 encoded version of the icons, which allows me to embed the image in the CSS. Learn more about Base64 encoding your assets. When you use Iconfinder to find icons, you also have the option to grab the Base64 encoded version straight from the site.

How to Add Icon Fonts to Any Element With CSS, List icons can; be used to; replace bullets; in lists class="fas fa-spinner fa-pulse​"></i></span>replace bullets</li> <li><span class="fa-li"><i <div class="fa-4x"> <i class="fab fa-font-awesome"></i> <i class="fab fa-cloud-download-alt tag. f02b. fa-tags. tags. f02c. fa-tasks. Tasks. f0ae. fa-thumbtack. Thumbtack. f08d. Font Awesome 4 is so 2017. Upgrade to version 5 and get twice the icons.