Since I was trying to find a solution with older browser support, I have what might be an over-simplified solution. Using table display styles and ids/classes:
<ul>
<li id="listCaption">My List</li>
<li>first item</li>
<li>second item</li>
<li>third item</li>
</ul>
Then apply the display: table-row;
style to the element in CSS:
li#listCaption {
display: table-row;
font-size: larger;
text-decoration: underline; }
This works much better if you are using a description list, which is what I was doing when I had the same question. In that case, you can use <div>
in the HTML and display: table-caption;
in CSS, as div elements are supported within the dl list:
<dl>
<div id="caption">Table Caption</div>
<dt>term</dt>
<dd>definition</dd>
</dl>
In CSS you can apply various styles to the caption:
#caption {
display: table-caption;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
background: transparent;
caption-side: top;
text-align: center; }
I should note that table-caption
does not work as well in ul/ol
as it is treated as a block element and the text will be aligned vertically, which you probably don't want.
I tested this in both Firefox and Chrome.