Are the close teg really needed?

Tell us what’s happening:

before i type in the close tag, the text “hello world” shows up in the result box.

Your code so far


<h1>Hello</h1>
<h1>Hello World</h1>
<h1>hahahaha</h1>

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36.

Challenge: Say Hello to HTML Elements

Link to the challenge:

Yes, they are needed. Although the “Hello World” will appear, if you omit closing tags, the HTML that comes afterwards will be messed up. The closing tag tells the browser “This part is done, let’s go on the the next part.”

2 Likes

The reason is that everything you are typing there is enclosed/wrapped inside the body tags so it will always render/show up. The body element shows anything within it.

Answer: Yes closing tags are needed .
Otherwise every element that comes next will be affected by the element that you didn’t close, in terms of styling, etc.

But note that there are some elements called empty elements which won’t need any closing tags , you’ll see along the way.

1 Like