Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i put text after <li></li> tag?

I'm wondering, can I put text after Li tag and will it be correct? Example

<ul>
    <li>Text</li>
    Text here after tag
    <li>Text</li>
    Text here after tag
</ul>

Writing such a code will return dots from li tags indented and that's what I want to achieve.

like image 394
Tukkan Avatar asked Nov 18 '25 18:11

Tukkan


2 Answers

Regarding your screenshot - the following code does what you want

<ul>
    <li>Text</li>
    <span>Text here after tag</span>
    <li>Text</li>
    <span>Text here after tag</span>
</ul>

css

span {
    margin-left: -15px;
}

And here is a fiddle: http://jsfiddle.net/P2CXF/

Note that the W3C markup validator will throw errors. The <span> tag is not allowed as child of <ul>

EDIT:

This one will validate (thank you @Ma3x)

<ul>
    <li>Text<br />
    <span>Text here after tag</span></li>
    <li>Text<br />
    <span>Text here after tag</span></li>
</ul>

You can also use <p> instead of <span>.

like image 182
5pike Avatar answered Nov 21 '25 08:11

5pike


Using <br /> instead like this:

<ul>
<li>Text<br />Text here after tag</li>

<li>Text<br />Text here after tag</li></ul>

Will produce the same effect and make a little more sense semantically if all you were intending to do was break the text down to the next line.

fiddle

like image 43
Nick Avatar answered Nov 21 '25 08:11

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!