Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Forms Inputs

Form Input does not have closing tag

Hello,

I just want to clarify, why does form INPUT does not have closing tag?

Lets say that the code is below

<input type="radio" name="gender" value="Male">Male

Why don't we do it like this

<input type="radio" name="gender" value="Male">Male</input>

Thank you before!

2 Answers

Hayden Taylor
Hayden Taylor
5,076 Points

Some html elements such as the input element are single tags because they don't need a closing tag. Its about efficiency. Html has a bunch of tags which are like this. It boils down to "Element Content" which is anything you put between 2 tags where as the input tag: what kind of content would you want between it? These tags have specific functionality already and they aren't meant to be manipulated with adding content between them.

Thank you, very informative!

Jumah Hamilton
Jumah Hamilton
8,648 Points

Christian,

I am not sure what you are looking for but here is a stab at it.

'Form' does have a closing tag, 'Input' does not.. Not sure why this exists though.

<form> 

 <input> 

</form>