0

Right sintax

Guys I found that writing <hr> and <hr/> it's the same, and even without the / it's work properly, can someone tell me if it's right or wrong doing this? Because even when I write <img> without / work also, plz I need some explanation.

31st Aug 2017, 2:41 PM
Daniel Lucas Aguas
Daniel Lucas Aguas - avatar
3 Answers
+ 4
The right sYntax is without the ending slash (/): this is the only valid way in Html5... Previously to Html5, it was valid syntax to be compatible with XHtml and Xml document/syntax. However, XHtml was abandonned with outcome of Html5, and last specifications no more allows the ending slash for empty/self-closed tags. Anyway, one main characteristic of Html is its permissivity: browsers are intended to display as well as they can even invalid document, so little mistake are easily corrected (ie: correcting <hr/>, <br/>, <img/> to <hr>, <br>, <img> rarely aren't enough explicit), but you cannot be sure of how each browser will react (and all the more if context is less explicit, as a bad <hr> inside a <p></p>, wich is not valid, and more complex to determine how to correct it), and search engine robots will not be as much comprehensible with your invalid code than nicely browsers ;P
31st Aug 2017, 6:52 PM
visph
visph - avatar
+ 1
Can you give an example of your code?
31st Aug 2017, 2:52 PM
Bobby Lindsey
0
For example this <html> <head> <title>first page</title> </head> <body> <h1>blabla<hr>bla</h1> <img src="http://www.sololearn.com/images/tree.jpg" alt=""> </body> </html>
31st Aug 2017, 2:56 PM
Daniel Lucas Aguas
Daniel Lucas Aguas - avatar