Jump to content

musicman

Recommended Posts

Because some tags (such as <input/> and <img/> and <br/> and <hr/>) are singular tags and have no legal closing tags. Browsers are designed to be forgiving and they try to make sense of illegal syntax, however HTML validators are designed to be precise and unforgiving.

<button id="btn1">Press Here</button>

<input type="button" id="btn2" value="Press Here"/>
  • Like 1
Link to comment
Share on other sites

It may work, but it not truly valid, <img> is for html and the end slash <img /> is required for xhtml, closing tags </div> are for those elements that can hold content and other elements within them. Those elements such as hr, br that are not capable of holding content of any kind are known as void elements.

  • Like 1
Link to comment
Share on other sites

hmm, then this case is a bit weird.

 

on my app, WePro, I'm using an iframe to show snippets html files. When the snippet html files use <br>, I got error message and the html file won't show on the iframe. It says: "mismatched tag. Expected: </br>". (Mozilla)

 

 

Link to comment
Share on other sites

I believe the closing slash at the end of singular tags has always been optional but it was required in XHTML.

 

In HTML5 it is clearly stated that this slash is optional, but in HTML5 a lot of stuff is optional -- to such an extent that most code-writers refuse to produce the horrible-looking stuff that HTML5 will accept as perfectly legal.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...