Another easy possibility would be to wrap the list item content into a <p>
, style the <li>
as bold and the <p>
as regular. This would be also preferable from an IA point of view, especially when <li>
s can 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 generic approach (that would also cover other scenarios like <li>
s with descendants other than <p>
, you might want to 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 the list item 4 here which is ol/li/code and not ol/li/p/code here.)
Just make sure to use the selector li > *
and not li *
, if you only want to style block level descendants as regular, but not also inlines like "foo <strong>
bold word</strong>
foo."