• Ite...">
    All geek questions in one place

    How to style each list item in an unordered list without an inline style?

    I have this unordered list:

    <div id="topmenudiv">
      <ul>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
        <li>Item 4</li>
        <li>Item 5</li>
      </ul>
    </div>
    Run code

    How can I access each tag lito style each individually using CSS without using an inline style?

    +4
    html css
    user2175784 Jul 21 '15 at 17:16
    source share
    2 answers

    If you want to style each element of the list differently, you can use the nth-child selector :

    /* First item */
    li:nth-child(1) {
      color: red;
    }
    
    /* Second item */
    li:nth-child(2) {
      color: blue;
    }
    
    
    /* Add additional items */
    <div id="topmenudiv">
      <ul>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
        <li>Item 4</li>
        <li>Item 5</li>
    </ul>
    </div>
    Run code
    +8
    Steve sanders Jul 21 '15 at 17:19
    source share

    Use this:

    #topmenudiv ul li {
    
    }
    
    0
    jrath Jul 21 '15 at 17:17
    source share

    Source: https://habr.com/ru/post/1598930/

    More articles:

    • Run a command from java that may contain spaces - java
    • Advancement in evaluating constant integer expressions in preprocessor directives - GCC - c
    • https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1598927/gmapnet-marker-at-incorrect-position-but-when-the-map-is-zoomed-the-marker-goes-to-right-place&usg=ALkJrhjO26LFwlZ9FjyErKTpuaSFzMfNKg
    • In java, how to initialize final parameters after a loop that can or not initialize them - java
    • GMap marker is placed in the wrong position - c #
    • How to change background color in ttk.Combobox list? - python
    • Failed to click on the hero after removing the submodule - git
    • Migration from Joda time to Java 8 DateTime - java
    • What errors / typos are supported in Python? - python
    • "JNDI name is already in use" in Weblogic 12c with EJB3 - java

    All Articles

    Geek Questions | 2019