About a year later, but since it may also be interesting for others coming here in the future:
Another simple possibility is to wrap the contents of the list item in <p> , the <li> style as bold, and <p> as usual. It would also be preferable from the point of view of IA, especially when <li> may contain sub-lists (to avoid mixing text nodes with block-level elements).
Full example for your convenience:
<html> <head> <title>Ordered list items with bold numbers</title> <style> ol li { font-weight:bold; } li > p { font-weight:normal; } </style> </head> <body> <ol> <li> <p>List Item 1</p> </li> <li> <p>Liste Item 2</p> <ol> <li> <p>Sub List Item 1</p> </li> <li> <p>Sub List Item 2</p> </li> </ol> </li> <li> <p>List Item 3.</p> </li> </ol> </body> </html>
If you prefer a more general approach (which will also cover other scenarios like <li> with descendants other than <p> , you can use li > * instead of li > p :
<html> <head> <title>Ordered list items with bold numbers</title> <style> ol li { font-weight:bold; } li > * { font-weight:normal; } </style> </head> <body> <ol> <li> <p>List Item 1</p> </li> <li> <p>Liste Item 2</p> <ol> <li> <p>Sub List Item 1</p> </li> <li> <p>Sub List Item 2</p> </li> </ol> </li> <li> <p>List Item 3.</p> </li> <li> <code>List Item 4.</code> </li> </ol> </body> </html>
(Check here for list item 4, which is ol / li / code, not ol / li / p / code here. Just make sure you use the li > * selector, not li * , if you want descendants of the block level styles were regular, but were also not lines like "foo <strong> bold word </strong> foo."
Stefan Gentz Dec 08 '14 at 2:44 a.m. 2014-12-08 14:44
source share