What do you call tags that need no ending tag?

2019-01-21 10:20发布

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?

12条回答
Bombasti
2楼-- · 2019-01-21 10:56

Those tags are called "Standalone Tags". Standalone tags are having no closing tags in HTML

But in XHTML they have to be self closed by adding forward slash before the closing angular bracket

查看更多
再贱就再见
3楼-- · 2019-01-21 11:01

There are paired and unpaired tags.

Unpaired tags are opened and do not have to be closed. They stand alone.

<img />, <input /> and <button />
查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-21 11:03

This sort of Element is an empty element (since it does not contain anything, it just may have attributes). That's the correct way according to the specification, AFAIK. (If the Element is not empty, the Element consists of the opening tag, the closing tag, and the content inbetween.)

Those tags are also called "unpaired", "single", or "bachelor tags". The term "self-closing" I don't like because they don't close themselves any more than other tags, it's still you or your program that puts the "/>" in there.

查看更多
趁早两清
5楼-- · 2019-01-21 11:05

The term is self-closing.

查看更多
走好不送
6楼-- · 2019-01-21 11:06

I've called them self-closing, single tags and monotags, I don't know why I haven't adopted a single term though.

查看更多
Viruses.
7楼-- · 2019-01-21 11:08

I've seen them referred to as singlet (Which is presumably a short form of single-tag)

查看更多
登录 后发表回答