Which way is correct? Closing tags

Is one of the the right way, and all the others are wrong?

Wrong or right?
'/></div>

Wrong or right?
'></div>

Wrong or right?
;"> </div>

Wrong or right?
;"/> </div>

<div></div>

Would be correct

Yea, I cleared it up:
https://validator.w3.org/nu/#textarea

In HTML, there is NO trailing slash for empty tags such as meta tags or img tags.

The trailing slash is an Xhtml convention.

Containers must be closed in HTML.

1 Like

There is always a closing tag in HTML. like <p> </p> <title> </title>. In this case div tag must be closed <div> </div>

I know about the div tag, I was more specifically talking about the '/> before it.

'/>

'>

;">

;"/>

There is NEVER such a closing slash in HTML.

Which is why this would be correct.

<img src=" " alt=" ">

Yes, (except that you are missing a closing quote mark after the alt attribute :smile: )

1 Like

The div tag pair consists of <div></div> - an opening tag and a closing tag, just like other tag pairs such as <p></p>, <a></a>, <h1></h1>, <span></span>, etc. (Some tags, such as <img> and <br> are self-closing and don’t require a separate closing tag.)

If you have attributes inside a tag, then you need to ensure that any opening quote marks - " or ’ - are also closed.

<div class="whatever">Content here</div>

<img src="https://placebear.com/g/200/300" width="200" height="300">

<a href='https://www.sitepoint.com'>Link to SitePoint</a>

<div style="overflow:hidden; width:150px; height:150px; border-radius: 50%; background-color: green;">Some content</div>

But those quotation marks are part of the attribute; they are not part of the HTML tag. Don’t confuse two different things.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.