How to select text within li using css [duplicate]


Tags: css

Problem :

This question already has an answer here:

I have following HTML markup enter image description here

How do i select text inside this

  • As you can see inside that

  • there is a div i dont want to affect contents on that div.



  • Solution :

    You can't select only that text. So style the div too:

    ul,
    li div {
      color: black;
    }
    li {
      color: green;
    }
    <ul>
      <li>
        Text
        <div>Div Text</div>
      </li>
      <li>
        Text
        <div>Div Text</div>
      </li>
    </ul>


      CSS Howto..

      how to remove a CSS property using jquery

      How to debug CSS bundled by Webpack?

      How to create such layout in CSS?

      JavaFX - Where is the css file for definition of StageStyle located or how can I change it?

      How to concatenate icons into a single image with ImageMagick?

      Compiling Bootstrap in LESS - How can I have a different navbar height for mobile?

      JSP/HTML / JS / CSS - How to create a cancel button in form

      In Python, I can print HTML to the browser, how can I ensure that the CSS that relates to it also get “printed”

      How to align images and urls within div trees in CSS?

      how to target individual elements in grails g:render

      JS+CSS How to display images from an array from top right to bottom left

      CSS: How to create a
    • with 100% width
    • How do I display div's next to each other within a wrapper div?

      How to do multiple class selectors in Stylus CSS pre-processor

      How do I keep floated child divs from wrapping?

      jQuery, given a Variable with DIV with items, how to scroll an Item to the Left

      How do I set a cell background colour based on its contents using PHP after reading values from MySQL?

      How to setup counters for target-counters

      How to convert this CSS animation to use GPU level, instead of updating layer tree

      How do I apply an outline to a custom styled HTML selection element's expansion clickable element only?

      How to scale a fixed-width website to an iPad viewport

      How to change a div top margin without leaving a white space?

      How to match element containing another element?

      How to achieve image changing on hover?

      How to create 'greater than' arrow using CSS only?

      How to use SASS logic within a CSS 3 media query [duplicate]

      How to decrease CSS opacity

      How to get rid of the white vertical stroke after every repeating background image done with repeat-x value in CSS?

      How would you replicate these boxes in CSS?

      How to trigger onClick event properly