RoiEX RoiEX - 7 months ago 27
HTML Question

Is style="display: list-item" using <a> tag inside <ol> legal?

I just discovered the

display: list-item;
option in CSS, but I'm not sure on how to use it correctly. It works fine for me in Firefox using:

<ol>
<a href="target.php" style="display:list-item;">TargetLink</a>
</ol>


But Eclipse tells me that it is not supposed to be used like this (warning: invalid location of tag a)

I tried without
<ol>
or with a
<div>
tag with
style="list-style-type: decimal;"
instead, but this way every entry is the
0
.

How
is style="display: list-item;"
supposed to be used?

Answer

I think you can use display: list-item like this, also only li can be direct children of ul and ol

.item {
  display:list-item;
  list-style-type: square;
  list-style-position: inside;
}
<p class="item">Lorem ipsum dolor.</p>
<p class="item">Lorem ipsum dolor.</p>
<div class="random">Lorem ipsum dolor.</div>
<div class="item">Lorem ipsum dolor.</div>