HTML elements

The html.elements vocabulary provides words for writing HTML tags to the output-stream with a familiar look and feel in the code.

HTML tags can be used in a number of different ways. The simplest is a tag with no attributes:
<p> "someoutput" write </p>

In the above, <p> will output the opening tag with no attributes. and </p> will output the closing tag.
<p "red" =class p> "someoutput" write </p>

This time the opening tag does not have the '>'. Any attribute words used between the calls to <p and p> will write an attribute whose value is the top of the stack. Attribute values can be any object supported by the present word.

Values for attributes can be used directly without any stack operations. Assuming we have a string on the stack, all three of the below will output a link:
<a =href a> "Click me" write </a>

<a "http://" prepend =href a> "click" write </a>

<a [ "http://" % % ] "" make =href a> "click" write </a>

Tags that have no “closing” equivalent have a trailing tag/> form:
<input "text" =type "name" =name 20 =size input/>

For the full list of HTML tags and attributes, consult the word list for the html.elements vocabulary. In addition to HTML tag and attribute words, a few utilities are provided.

Writing unescaped HTML to html.streams:
write-html ( str -- )

print-html ( str -- )