I'm aware that <span>
tag is an inline element while <li>
is a block element. However, we have a tooltip that uses a <span>
tag and we'd like to make the text inside that tooltip into a list. However, putting <ul><li>
inside span doesn't work in all browsers (and it's invalid).
This is the HTML code:
<a class='tooltip'>Text<span>Text that we want to become a list</span></a>
Is there a possible work around?
Although I would not worry to much about invalid code in this instance, given that you know about it, if the ul li
is breaking in some of the code, you could do the following, which is also probably invalid:
<a class='tooltip'>Text<span>List item 1<br />
List item 2<br />
List item 3</span></a>
I think the technical answer you could be looking for is that the tooltip text should go inside the title attribute of the anchor tag itself.
<a href="link.htm" title="•List item 1 •List item 2 ">Text</a>
It's still not "beautiful" but semantically it's closer to what you're looking for. Plus you can use javascript to pluck that title value from the anchor tag to do something prettier with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With