Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML How to Make a Website HTML First Build Structure

rajbee
rajbee
6,657 Points

why don't we need to close the meta tag like the other ones ?

We open and close tags like this: <h1>heading</h1>. Why don't we do <meta charset="utf-8"> </meta> ?

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Raghav and Welcome to Treehouse.

In HTML (and a few other languages), there will be self-closing (or "Empty") tags.

For an in-depth explanation and some examples, please see this MDN Documentation.

Keep Coding! :)

Hey Raghav!!

I'm sorry to be "that guy". I looked on the web to help find an answer to your question. Here's what I found.

http://stackoverflow.com/questions/19506028/do-you-need-to-close-meta-and-link-tags-in-html

*"In XHTML, XML rules apply, so every element, without exception, must have both a start tag and an end tag, but the same tag may be used for both roles if the element content is empty,

e.g. <meta name="foo" content="bar"/> 

as short for

<meta name="foo" content="bar"></meta>.

If you violate this when serving a document with an XML (XHTML) content type to a conforming browser, then your document is not displayed at all; an error message is shown instead.*

When using XHTML server with HTML content type (Content-Type: text/html), as XHTML documents almost always are on the web, then browsers will actually apply the non-XHTML HTML rules.

To summarize:

+normally, use just

<meta ...>

with no

/

+if you are really using XHTML in a context where XHTML parsing is actually applied, play by XML rules (and make sure you know them)

+if your boss tells you to write ```<meta ... />

, do so; it’s not useful, but it causes no harm (except if you try to validate e.g. agaist HTML 4.01 doctype)."*

-Jukka K. Korpela

++++++++++++++++If you look at the link, it shows even more information on it!++++++++++++

I Hope this helps!!!

Abhishek Kambli
Abhishek Kambli
2,657 Points

This Are empty tags/ Stand alone tags, so there is no need to close them, In future you will encounter more empty tags like <img> i.e for inserting image or <hr> for adding a horizontal line