Can I use <li> tag without /?

image
I wonder can I use “li tag” without finishing?

2 Likes

Nope you can’t.
As it won’t know you want to go to the next listing. It will also mess up the order.

You have to have an opening and closing tag to specify each listing.

2 Likes

But when I try it with only one ending at the and of order it’s works well or there is mistake somewhere?

2 Likes

You mean like this:

<ul>
    <li> someth list
    <li> some list  </li>
</ul>

Having only one closing li tag ?
The browser could be printing out correctly and overlooking your mistakes, but it’s not good to do things against the rules as when other code is added it could become an issue

2 Likes

Thanks! Now I got it, then I will play more safe next time.

3 Likes

HTML5 is quite forgiving when it is obvious what we are doing.

<ul>
  <li>list item one
  <li>list item two
  <li>list item three
  <li>list item four
</ul>

So long as the </ul> tag is present, we can leave off the other endtags as they are implicit, given another <li> is present immediately following and the list itself is closed. The code may validate, but with a warning.

The same applies to <p> when followed by another <p>.

<div>
  <p>paragraph one
  <p>paragraph two
  <p>paragraph three
  <p>paragraph four
</div>

We should not expect all browsers to be this forgiving, though. Best practice is to close all elements with the appropriate endtag.

3 Likes