CSS to select all li in ul
Asked Answered
P

3

11

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?

Protozoal answered 17/9, 2012 at 17:42 Comment(1)
Any ul element or just one particular such element? This goes down to just about the basics, and I suggest you peruse the many existing basic tutorials/guides out there which have the basics widely covered, as well as use search.Pregnancy
S
35
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.

Straitjacket answered 17/9, 2012 at 17:43 Comment(3)
Probably, someone else with a duplicate answer.Straitjacket
+1 the first to answer. but the second part was enough according to OPIcy
@Icy well, better than always doing only the minimum just for being first and trying to get upvotes, right?Galengalena
B
5

This should work:

ul li { /*css here */}
Becker answered 17/9, 2012 at 17:44 Comment(0)
R
3

You can use

 ul li {
  /* your code here */
 }
Roundshouldered answered 17/9, 2012 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.