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?
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?
2
Answers
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:
or like this if it is following the xhtml standard:
The slash at the end is useless the browser ignores it, unless you want your HTML to be compatible with XML because XHTML is different it is like HTML but with XML rules/standards, so if you don’t care about XML you can ignore it.