Take the 2-minute tour ×

There are those tags which have immediate effect (< br >) and those which affect what is between them ( < a > < / a > ).

Closing tag is verbose, and I believe also redundant:

<tag parameters> ... </tag>


Compare to LISP's s-expresions.

(tag parameters)


Ending tags are not even necessary. These language are context-free and this is not possible there:

<tag1> <tag2> </tag1> </tag2>

Basically these should be equivalent:

<tag1> <tag2> </> </>
<tag1> <tag2> </tag2> </tag1>       


Are ending tags there to aid readability? What is purpose of redundancy in closing tags? I want to understand inside the logic behind desing of this. Thanks. :)

share|improve this question
Your example: <tag1> <tag2> </> </> is nice when you only have 1 line. Think of a file that 10M and you have a missing close tag. How do you identify which one is missing. –  Loki Astari Oct 27 '11 at 15:16
@Loki True.:) I see Your point, but doing such file by hand? –  user712092 Oct 28 '11 at 16:54
@Loki Offtopic: Imagine it would be <tag1 <tag2 >>, so for example <tag1 some huge amount of text <tag2 another huge amount > third huge amount > fourth huge amount. You can jump from beginning to the end of such tag, in editors who support it (in Vim, it is just by %, so it is very easy thing). Parameters, for they must be there and they must not break previous rule, might be then something like <tag #parameters # text and tags enclosed> ... –  user712092 Oct 28 '11 at 17:08
Though you may use tool and special editors to build your basic HTML document they always very general and I always end up finishing the editing by hand editing the HTML. –  Loki Astari Oct 28 '11 at 17:40

3 Answers 3

up vote 10 down vote accepted

In the case of XML, Tim Bray outlines the design goals in his annotated version of the XML spec http://www.xml.com/axml/target.html#sec-origin-goals.

The design goals for XML are:

  1. XML shall be straightforwardly usable over the Internet.
  2. XML shall support a wide variety of applications.
  3. XML shall be compatible with SGML.
  7. The XML design should be prepared quickly.
  8. The design of XML shall be formal and concise.
  9. XML documents shall be easy to create.
  10. Terseness in XML markup is of minimal importance.

The annotation for goal 10 is:

Terseness is of Minimal Importance

The historical reason for this goal is that the complexity and difficulty of SGML was greatly increased by its use of minimization, i.e. the omission of pieces of markup, in the interest of terseness. In the case of XML, whenever there was a conflict between conciseness and clarity, clarity won.

Rick Jelliffe has some more background in http://www.oreillynet.com/xml/blog/2008/01/the_design_goals_of_xml_1.html

share|improve this answer
thank You very much :) –  user712092 Oct 27 '11 at 12:33

In your question title, you ask about HTML, SGML and XML as if they are the same thing, but they are not. In fact, they are very different in precisely that area which you are asking about.

In particular, SGML has both Null End Tags and Implied End Tags (and Implied Elements as well), and since HTML is an application of SGML, it inherits those.

Null End Tags allow you to leave out the name of the End Tag. Instead of


You can also write


Implied End Tags allow you to leave out the End Tag altogether, if it is clear from the context that there must be an End Tag. For example, in HTML, a body element cannot be inside a title or head element, therefore you can write

    <title>The Title

and both the title and head elements will be implicitly closed.

End Tags are also implied at the end of the document: all elements will be closed in reverse order.

With Implied Elements, you can leave out both Start and End Tags: since p is only allowed within body, the first p will imply a body:

    <title>The Title

Here, there is a body element in the document, even though there are no body tags.

Putting it all together, you get something like this:

  <HEAD /
    <TITLE / > /
    <P / >

This is a complete, 100% well-formed, 100% valid HTML document. (Well, it's missing the DOCTYPE declaration, but if you add one, you can run it through the W3C validator as HTML 1.0, 2.0, 3.2 and 4.01, even as Strict.)

It is semantically equivalent to the following XHTML:


Now, which one of the two is easier to read? (Actually, that's a serious question. I'm particularly interested in what seasoned Lisp programmers have to say.)

share|improve this answer

Yes, ending tags are there to aid readability and clarity in case of error. If a document is malformed and missing an end-tag, how would the developer be sure which tag is missing?

Also, I suspect that having the name in the end-tag aids in SAX-type parsing, allowing the parser to easily identify the type of node that is being ended.

share|improve this answer
Thank You. :) Could You please just find a source for it? –  user712092 Oct 26 '11 at 23:58

Your Answer


