Skip to content

HTML

Tags

Regular tags (closed)

html
<div></div>
json
{
  type: "element",
  tagName: "div",
  attributes: [],
  children: [],
  void: false,
  closed: true
}

Regular tags (open)

html
<div>
json
{
  type: "element",
  tagName: "div",
  attributes: [],
  children: [],
  void: false,
  closed: false
}

Self-closing tags

html
<img />
json
{
  type: "element",
  tagName: "img",
  attributes: [],
  children: [],
  void: true,
  closed: true
}
html
<div />
json
{
  type: "element",
  tagName: "div",
  attributes: [],
  children: [],
  void: true,
  closed: true
}

Namespaced tags

html
<ns:table></ns:table>
json
{
  type: "element",
  tagName: "ns:table",
  attributes: [],
  children: [],
  void: true,
  closed: true,
  namespaced: true // maybe?
}

Attributes

Double quoted attribute

html
<input class="input input-text" />
json
{
  type: "element",
  tagName: "input",
  attributes: [
    {
      type: "attribute",
      name: "class",
      value: "input input-type",
      quote: "double"
    }
  ],
  children: [],
  void: true,
  closed: true
}

Single quoted attribute

html
<input class='input input-text' />
json
{
  type: "element",
  tagName: "input",
  attributes: [
    {
      type: "attribute",
      name: "class",
      value: "input input-type",
      quote: "single"
    }
  ],
  children: [],
  void: true,
  closed: true
}

None-quoted attribute

html
<input class=input />
json
{
  type: "element",
  tagName: "input",
  attributes: [
    {
      type: "attribute",
      name: "class",
      value: "input",
      quote: "none"
    }
  ],
  children: [],
  void: true,
  closed: true
}

Empty attribute

html
<div class=""></div>
json
{
  type: "element",
  tagName: "input",
  attributes: [
    {
      type: "attribute",
      name: "class",
      value: "",
      quote: "double"
    }
  ],
  children: [],
  void: true,
  closed: true
}

Boolean attribute

html
<input required />
json
{
  type: "element",
  tagName: "input",
  attributes: [
    {
      type: "attribute",
      name: "required",
      value: true
    }
  ],
  children: [],
  void: true,
  closed: true
}

Content

No content

html
<h1></h1>
json
{
  type: "element",
  tagName: "h1",
  attributes: [],
  children: [],
  void: false,
  closed: true
}

Text content

html
<h1>Title</h1>
json
{
  type: "element",
  tagName: "h1",
  attributes: [],
  children: [
    {
      type: "text",
      value: "Title"
    }
  ],
  void: false,
  closed: true
}

HTML tags

html
<h1>
  <span>Title</span>
</h1>
json
{
  type: "element",
  tagName: "h1",
  attributes: [],
  children: [
    {
      type: "element",
      tagName: "span",
      attributes: [],
      children: [
        {
          type: "text",
          value: "Title"
        }
      ],
      void: false,
      closed: true
    }
  ],
  void: false,
  closed: true
}

HTML tags + Text content

html
<h1>
  Version
  <sup>1.0</sup>
</h1>
json
{
  type: "element",
  tagName: "h1",
  attributes: [],
  children: [
    {
      type: "text",
      value: "Version"
    },
    {
      type: "element",
      tagName: "sub",
      attributes: [],
      children: [
        {
          type: "text",
          value: "1.0"
        }
      ],
      void: false,
      closed: true
    }
  ],
  void: false,
  closed: true
}

Comments

Regular

html
<!-- Comment -->
json
{
  type: "comment",
  value: " Comment "
}

Multi-line

html
<!--
  Comment
  On
  Muliple
  Lines
-->
json
{
  type: "comment",
  value: "  Comment\n  On\  Multiple\n  Lines"
}

Released under the MIT License.