Jump to content

Closing elements > or />


davidb52

Recommended Posts

Hello,I'm wondering if this is allowed, and for so far I can't find the answer.For elements likemetaimgHow do you close it? Because you only need "1" element (<img src="">) not 2 like (<a href=""></a>)So:<meta charset="utf-8"><img src="images/layout/logo.png" width="266" height="100" alt="Logo"> or<meta charset="utf-8" /><img src="images/layout/logo.png" width="266" height="100" alt="Logo" /> notice the / Thanks,David

Link to comment
Share on other sites

Just follow the tutorials and pay attention to validation errors. For example, see: Differences Between HTML and XHTML at http://Differences Between HTML and XHTML If coding was incredibly easy, everyone would be doing it. I would use validation errors as the acid test.

Edited by niche
Link to comment
Share on other sites

MM, link doesn't work.But I'm using html5. http://dev.w3.org/html5/html-author/doesn't tell anything about what to use... http://www.w3schools.com/html5/tag_meta.aspin the example that you can try, they use />. While later they use "HTML5: <meta charset="UTF-8">" So what is the best way?The validator doesn't say anything about it...

Link to comment
Share on other sites

It depends on which DTD you're using on your page. HTML DTDs will only accept the >, as in <img ... > while XHTML DTDs will only accept the />, as in <img ... /> HTML 5 is the exception which will support either > or /> so neither one is more correct, though some would recommend using > just because it is an HTML DTD.

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...