Home > Net >  Why does the tag name has to be specified in a closing tag [HTML,XML,...]
Why does the tag name has to be specified in a closing tag [HTML,XML,...]

Time:11-19

In XML, Html and Co you need to specify which tag you want to close. For Example:

<A>
  <B>
  </B>
</A>
<C>
</C>

But logically you could leave them away like this:

<A>
  <B>
  </>
</>
<C>
</>

The transfered information would be same, which should be crucial in a data format like xml. It seems illogical to me to increase the data size by up to 10% or so just to make it a bit more readable. So why is it like that?

CodePudding user response:

This was hotly debated when the spec was defined, and the authors had a lot of SGML experience to draw on. The consensus was that when hand-authoring, (or when generating XML using buggy code) it's much easier to diagnose tag mismatches if the end-tag names are required. They also argued that it was increasingly common for network transfers to use data compression, which reduces the overhead of the redundant names almost to zero.

CodePudding user response:

For readability; especially when we have lots of lines of code. There is generally a trade-off when creators design rules for things like these.

  • Related