The HTML4 specification mentions various SGML shorthand markup constructs. While I understand what others do, with a help of HTML validator, I cannot find understand why anyone would want an empty start tag. It cannot even have attributes, so it's not a shorter <span>
.
The SGML definition of HTML4 enables the empty start feature. In it, there is an interesting section with features.
FEATURES
MINIMIZE
DATATAG NO
OMITTAG YES
RANK NO
SHORTTAG YES
LINK
SIMPLE NO
IMPLICIT NO
EXPLICIT NO
OTHER
CONCUR NO
SUBDOC NO
FORMAL YES
APPINFO NONE
The important section of features is MINIMIZE
section. It enables OMITTAG
which is a standard feature of HTML, which allows start or end tags to be ommited. This is particular allows you to write code like <p> a <p> b
, without closing paragraphs.
The more important part is SHORTTAG
feature, which is actually a category. However, because it's not expanded, the SGML automatically assumed YES
for all entries in it. It has the following categories in it. Feel free to skip this list, if you aren't interested in other shorthand features in SGML.
ATTRIB
, which deals with attributes, and has following options.
DEFAULT
- defines whether attributes can contain default values. This allows writing <p>
without defining every single attribute. Nobody would want to write <p id="" class="" style="" title="" lang="en" dir="ltr" onclick="" ondblclick="" ...></p>
after all. Hey, I even gave up trying to write all that. This is a commonly supported feature.
OMITNAME
- if the attribute and value have the same name, the value is optional. This allows writing <input type="checkbox" checked>
for instance. This is a commonly supported feature (although, HTML5 defines default to be empty string, not an attribute name).
VALUE
- allows writing values without quotes. This allows writing code like <p class=warning></p>
for instance. This is a commonly supported feature.
ENDTAG
, which is a category for end tags containing the following options.
UNCLOSED
- allows starting a new tag before ending the previous tag, allowing code like <p><b></b</p>
.
EMPTY
- allows unnamed end tags, such as <b>something</>
. They close most recent element which is still open.
STARTTAG
, which is a category for start tags containing the following options.
NETENABL
- allows using Null End Tag notation. It's worth noting this notation is incompatible with XHTML. Anyway, the feature allows writing code like <b/<i/hello//
, which means the same thing as <b><i>hello</i></b>
.
UNCLOSED
- allows starting a new tag before ending the previous tag, allowing code like <p<b></b></p>
.
EMPTY
- this is the asked feature.
Now, it's important to understand what EMPTY
does. While <>
may appear useless at first (hey, how could you determine what it does, when nothing aside of Validator supports it), it's actually not. It opens the previous sibling, allowing code like the following.
<ul>
<li class=plus> hello world
<> another list element
<> yet another
<li class=minus> nope
<> what am I doing?
</ul>
In this example, the list has two classes, plus
and minus
for positive and negative arguments. However, the webmaster was lazy (and doesn't care about that HTML4 doesn't support this), and decided to use empty start tag in order to not specify the class
for next elements. Because <li>
has optional end tag, this automatically closed previous <li>
tag.