Jump to content

Closing elements > or />


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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...