There are HTML tags, such as <img />
, <input />
and <button />
, that need no ending tag (</img>
, </input>
and </button>
). What is the term that describes this type of tags?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
This syntax has a variety of names depending on what language you are using. The best way to find out what it is called is to look at the specification for the specific language.
HTML 4.x
I can't find any mention of this syntax in the HTML 4.x specification. It is not valid syntax.
HTML 5
In the HTML 5 specification the
/
character (called a SOLIDUS) is valid but has no effect for void elements such as<br />
,<hr />
,<img />
,<input />
, etc. and for foreign elements (such as SVG tags) it designates a start tag that is marked as self-closing. It is not a valid syntax for all other tags (such as<button />
mentioned in your question).XML
According to the XML specification it is called an empty-element tag:
XHTML
According to the XHTML specification it is called the minimized tag syntax for empty elements:
In general if you want to be precise I would recommend using the names as defined in the appropriate standard. Then if people aren't exactly sure what you mean they can look it up in the standard to find out. However if you don't want to use the name in the standard you are free to call it something else if you want. The important thing is that the people who communicate with you can understand you. I don't think anyone would misunderstand you if you used the term 'self-closing tag' for a tag in an XML document even if the standard officially calls it something else.
Thanks to Alohci for the HTML 5 reference.
I know them as bachelor tags.
e.g. here: http://moodle.cs.huji.ac.il/cs09/file.php/67782/xml-intro.pdf (page 30)
According to here:
I've always called them Singleton tags!
HTML tags can be of two types. They are
Paired Tags
Unpaired Tags
Paired Tags:
A tag is said to be a paired tag if the text is placed between a tag and its companion tag. In paired tags, the first tag is referred to as Opening Tag and the second tag is referred to as Closing Tag.
Example:
<i>
This text is in italics.</i>
Note: Here
<i>
is called opening tag. and</i>
is called closing tag.Unpaired Tags:
An unpaired tag does not have a companion tag. Unpaired tags are also known as Singular or Stand-Alone Tags.
Example :
<br> , <hr>
etc. These tags does not require any companion tag.That is called a self closing tag