CSS to select all li in ul

2019-06-19 02:40发布

问题:

I want to write a CSS selector that selects all li elements within a ul element in a document but I don't know how that would be done. Can you help?

回答1:

ul > li {
  /* css styles go here */
}

or

ul li {
  /* css styles go here */
}

the first selects only direct children the second selects all li nested within an ul.



回答2:

This should work:

ul li { /*css here */}


回答3:

You can use

 ul li {
  /* your code here */
 }