W3C home > Mailing lists > Public > www-validator@w3.org > January 2005

Re: closing slash at the end of the base HTML tag leads to an error

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Fri, 28 Jan 2005 11:08:32 +0200 (EET)
To: www-validator@w3.org
Cc: Jordan Laszlo <Laszlo.Jordan@firstdata.com>
Message-ID: <Pine.GSO.4.58.0501281052010.22907@korppi.cs.tut.fi>

On Thu, 27 Jan 2005, Paul Norman wrote:

> > The base element does not allow the closing tag at the end in HTML but
> > requires it in XHTML.
>
> That's since in XHTML every tag needs to be closed.

To remove potential confusion, I'd like to comment on this statement in
the otherwise accurate description. It is common to speak of elements as
tags, but here it really confuses.

Both in HTML and XHTML, every tag (every start tag and every end tag
there are in a document) needs to be closed. Normally a tag is closed by a
greater than sign ">", called TAGC (for "tag close") in some formal
contexts, including some validator messages. There are other ways to close
tags in HTML (but not in XHTML), but I'll skip them here, as they are not
supported by browsers.

Closing an _element_ is something different. Normally an element is closed
with an explicit end tag, such as </h1>, but HTML (not XHTML) allows
implicit closing too, e.g. a paragraph (p element) is implicitly closed by
the start tag of any block element.

Some elements such as base or br have EMPTY declared content, which means
that no content is allowed. In both HTML and XHTML, the start tags for
these elements are treated as acting as an end tag too, i.e. the element
is "self-closing". There's just a minor syntactic difference here, since
by XML rules, hence by XHTML rules, a parser needs to know from a tag's
appearance alone whether it denotes a "self-closing" element. This makes
it possible to parse an XML document without knowing anything about any
particular syntax used, still less any semantics.

So what the "every element needs to be closed in XHTML" slogan _really_
means is that
- for elements with EMPTY declared content, you need to use the specific
  syntax with a "/", such as <br /> (though, in principle, <br></br>
  is allowed too, but not recommended)
- for all other elements, an explicit start tag and an explicit end
  tag is required, e.g. every paragraph must be ended with </p>

Nobody really wants to know more, but there is a detailed explanation
of empty elements in SGML, XML, HTML, and XHTML:
http://www.cs.tut.fi/~jkorpela/html/empty.html

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/
Received on Friday, 28 January 2005 09:09:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:18 GMT