Home

selfclose

Selfclose, or self-close, refers to the syntax used in markup languages to denote an empty element that contains no content. It is commonly written as a self-closing tag, for example <tag/> in which the slash indicates the element has no inner content.

In XML and XHTML, empty elements are typically expressed with the self-closing form. Typical examples include

In HTML, the concept exists as void elements—tags that inherently do not have or require content, such

Usage and compatibility considerations vary by context. In XHTML or XML-based workflows, self-closing syntax is standard

See also: HTML, XML, XHTML, SGML, void elements, empty-element tag.

<img
src="..."
alt="..."/>
and
<br/>.
In
these
contexts,
the
self-closing
syntax
is
the
standard
way
to
declare
an
element
that
does
not
require
a
closing
tag.
as
<img>,
<br>,
<hr>,
and
<input>.
In
HTML5,
these
elements
do
not
require
a
closing
tag
and
may
be
written
with
or
without
a
trailing
slash.
The
slash
form
is
primarily
useful
for
XHTML
compatibility
or
for
tools
that
assume
XML-style
syntax.
For
non-void
elements
(like
<div>
or
<span>),
self-closing
them
with
a
syntax
like
<div/>
is
discouraged
in
standard
HTML
and
can
lead
to
parsing
inconsistencies
across
browsers.
for
empty
elements.
In
HTML5,
while
the
slash
is
allowed
in
start
tags,
it
is
generally
ignored,
and
authors
are
encouraged
to
use
the
traditional
start
tags
paired
with
appropriate
content.
Validators
may
flag
non-void
elements
written
as
self-closing
in
certain
HTML
contexts.