Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is / mandatory or not in html elements with no content?

My xhtml book says it’s a good practice to put "/" in elements with no content, such as hr, br, input type="button", etc.

Now the code editor says "Trailing slash on void elements has no effect", something like that.

Who’s right?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

xhtml is an older standard which required closing of html tags but the current standard html5 does not require that anymore.

Your editor is following the html5 standard and therefore does not require the tags to be closed.

Your html file should be opening like this to see if it is following the html5 standard:

<!DOCTYPE html>

or like this if it is following the xhtml standard:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading