W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2009

[whatwg] Syntax of void element

From: ATSUSHI TAKAYAMA <taka.atsushi@googlemail.com>
Date: Wed, 2 Dec 2009 12:18:05 -0500
Message-ID: <9cef076f0912020918h6aedfa52n6badb1f4d6c130d4@mail.gmail.com>
Hi WHATWG members,

This was posted by Akatsuki Kitamura on the W3C Japanese Interest
Group Mailing List.

The section 9.2.1 of HTML5 spec says;

Start tags must have the following format:
1. The first character of a start tag must be a U+003C LESS-THAN SIGN
character (<).
2. The next few characters of a start tag must be the element's tag name.
3. If there are to be any attributes in the next step, there must
first be one or more space characters.
4. Then, the start tag may have a number of attributes, the syntax for
which is described below. Attributes may be separated from each other
by one or more space characters.
5. After the attributes, there may be one or more space characters.
(Some attributes are required to be followed by a space. See the
attributes section below.)
6. Then, if the element is one of the void elements, or if the element
is a foreign element, then there may be a single U+002F SOLIDUS
character (/). This character has no effect on void elements, but on
foreign elements it marks the start tag as self-closing.
7. Finally, start tags must be closed by a U+003E GREATER-THAN SIGN
character (>).

As far as I understand, if I want to write a void element with no
attribute, such as the br, I do steps 1 ("<" character) and 2 (tag
name), then ignore 3 and 4. In the step 5, since I don't have any
attributes, the "after the attribute" situation does not apply here,
so I ignore it too. Then I close the tag by going through step 6 ("/"
character) and step 7 (">" character).

Akatsuki's question was that if you write space characters before
closing the tag like the following, if they are still valid or not.

<br >
<br />

I think the step 5 should be written as;

After the attributes, or after the element's tag name if there are no
attributes, then there may be one or more space characters.

Thanks,
A. Takayama
Received on Wednesday, 2 December 2009 09:18:05 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:54 UTC