Home

emptyelement

An empty element, in the context of markup languages, refers to an element that contains no content and has no child elements. In XML and XHTML, an empty element is expressed with a self-closing tag such as <tag/>. In HTML, the analogue is the concept of void elements: elements that cannot contain content and do not have a separate end tag.

Void elements in HTML include img, br, hr, input, meta, link, area, base, col, embed, param, source,

In XML and XHTML, the self-closing form is the standard way to denote emptiness; <tag/> is equivalent

In the DOM, an empty element has no child nodes. Methods like textContent or innerHTML would yield

track,
and
wbr.
These
elements
are
defined
by
the
HTML
specification
as
inherently
empty
and
should
not
enclose
content
or
be
written
with
a
separate
closing
tag
in
standard
practice.
Other
HTML
elements
can
be
written
with
opening
and
closing
tags
but
may
also
be
empty
if
they
contain
no
text
or
child
elements.
to
<tag></tag>
for
elements
with
no
content.
In
HTML,
the
self-closing
syntax
is
generally
ignored
for
non-void
elements,
and
whether
a
closing
tag
is
present
may
affect
parsing
results,
but
browsers
typically
treat
non-void
elements
with
no
content
as
empty.
an
empty
string
(apart
from
possible
whitespace).
Empty
elements
can
simplify
markup
and
reduce
data
size,
and
they
play
a
distinct
role
in
parsing
rules,
serialization,
and
template
processing
across
markup
languages.
See
also:
element,
void
element,
self-closing
tag,
XML,
HTML.