3 ms·
> The element/attribute distinction is because HTML is a markup language, where the primary content is text and markup is used to add structure and metadata.
by djedr 4y ago
> The element/attribute distinction is because HTML is a markup language, where the primary content is text and markup is used to add structure and metadata.
That may have been the idea, but it falls apart in implementation. Lines between content and metadata get blurred.
Consider attributes like: input/value, input/placeholder, optgroup/label, img/alt, title.
And then elements like: script, colgroup, col, title, noscript, noframes, applet, object, the void elements[0].
Then consider the ability of CSS to add content to elements, including lifting it from attributes[1], and, on the other side, completely hiding element contents.
The line between metadata and data is conventional. It's all data in the end.
But let's suppose it isn't and there is a hard line. Why should the metadata in attributes not be allowed to have structure and be extensible in the same way data is?
> You can eliminate attributes to get a simpler format, but it isn't really a markup language anymore, since the distinction between text and markup is removed. It is just a generic data structure, like JSON or s-expressions.
What I'm saying is that HTML-like attributes are not necessary to keep the distinction. You can keep the functionality, simplify things and at the same time make them more flexible.
HTML-like attributes also don't stop people from using the language to describe generic data structures (XML).
On the other side, if JSON or S-expressions had syntax and semantics that made them suitable as markup languages, I don't see a problem with that.
[0] https://developer.mozilla.org/en-US/docs/Glossary/Void_element https://developer.mozilla.org/en-US/docs/Glossary/Void_eleme...
[1] https://developer.mozilla.org/en-US/docs/Web/CSS/attr https://developer.mozilla.org/en-US/docs/Web/CSS/attr
- goto11 4y agoThe difference is not between tags and attributes, the difference is between text and markup. A markup language is human-readable text with added markup. A plain text file is basically a valid HTML file (I believe <title> is the only required element). You can then add markup to provide structure and metadata. This sets it apart from generic data structure formats. You can express the same information in JSON, but in JSON there is no distinction between text content and other information, it is all just structured data. Something like s-expression is clearly simpler than HTML syntax, and it is endlessly flexible, but it is just not optimized towards writing structured text content the way markup languages are.
- djedr 4y agoThat's more like it! Indeed, markup languages are built around text whereas in JSON/S-expressions/syntaxes designed for expressing data, text is secondary. The syntax I created is uniquely flexible in that it can be used for both data and markup. The first variant of the two in my original comment is more data-like, but minimal enough that it works sufficiently well as markup too. Text is a little harder to mark up in this variant than in HTML, as individual text nodes have to be wrapped in []. However this gives precise control over the content of the text nodes and separates indentation and other whitespace of the document tree from whitespace which is intended as actual content: [paragraph with a ] a [ href=[...] [link] ] The second variant is very much like HTML: text here is primary and interleaved with markup in []: paragraph with a [href[...] a][link] This variant also separates the attributes and tag from the children, much like HTML. However the attributes are technically not restricted to being flat strings. If we weren't translating to HTML, we could have attributes with tree structure. So we have something simpler and more flexible than both HTML and S-expressions. This is the beauty and value of it. I hope I can succeed in communicating this to potential users, so they can benefit from it.