Meta: HTML in the style of JSON Meta: HTML in the style of JSON json json

Meta: HTML in the style of JSON


I don't think that JSON will ever replace HTML.

There is more into HTML than a simple and portable data. JSON is, by design, an efficient data specification for any data that can be reduced to something like "inside this, you have this, and that, and that..". A JSON data must be dead simple and meant to be used anywhere. HTML is a language that allows nested complex items and have some strict rules, which is an heavy task for such a simple data specification.

Just an example:

HTML:

<nav id="menu-top">   <ul class="item-light">      <li>Cars</li>      <li>Horses</li>   </ul></nav>

could become this:

"HTON":

{    "nav": {       "id": "menu-top",       "ul": {          "class": "light-item",          "li": {             "Cars": "???"          }       },       ...    }}

But here, it would be hard to differentiate an element's own attributes of his nested elements. The easier to read the better.


HTML (even XHTML) is not XML, it can't, it's too lose:

<span>  what  <a href="">a</a>  mess</span>

Markup like this is essential to DOM and it's way to hard to replace it with JSON syntax because it has no room for "errors".

However there are a lot of tempting frameworks that allow you to be more "DRY" about HTML, like jade and haml.