Table of Contents | Previous: WebSockets | Next: Authentication
CL-HTTP generates HTML entirely from Common Lisp macros and functions. There are no template files, no embedded HTML strings, and no external templating engines. Every HTML tag is produced by a Lisp macro that ensures well-formed output: opening tags are always closed, attributes are properly quoted, and nesting constraints are enforced at compile time where possible.
The HTML generation facility is organized as a tower of packages, each building on the previous:
html2)
html3.2)
with-standard-document-body macro.
html4.0)
xhtml1.0)
html5)
header, footer, nav,
article, section, aside,
main, figure), interactive elements
(details, dialog), media elements
(audio, video), new form input types, and
HTML5 global attributes (hidden, contenteditable, draggable, data-*,
aria-*). Uses the simplified <!DOCTYPE html>
declaration.
The active HTML package is controlled by feature flags at system load time.
One of the packages is always nicknamed "HTML", so application
code that uses html:with-html-document automatically gets the
current version. Most code should use the HTML nickname
rather than version-specific package names.
*output-stream* ConventionAll HTML generation macros accept a :stream keyword
argument. When omitted, it defaults to *output-stream*,
a special variable defined in the HTML2 package:
(html2:define-parameter *output-stream* *standard-output* "The standard place where HTML operator output text.")
In a CL-HTTP response function, *output-stream* is
bound to the HTTP response stream. You can pass :stream
stream explicitly to every macro, or rely on the dynamic
binding:
;; Explicit stream passing (recommended for clarity):
(html:with-html-document (:stream stream)
(html:with-document-preamble (:stream stream)
(html:declare-title "My Page" :stream stream))
(html:with-document-body (:stream stream)
(html:with-paragraph (:stream stream)
(write-string "Hello, world." stream))))
;; Using *output-stream* (convenient for deeply nested code):
(let ((html:*output-stream* stream))
(html:with-html-document ()
(html:with-document-preamble ()
(html:declare-title "My Page"))
(html:with-document-body ()
(html:with-paragraph ()
(write-string "Hello, world." html:*output-stream*)))))
Every HTML page requires a specific nesting structure. CL-HTTP provides macros that enforce this structure:
with-html-documentWraps the entire page in <html>...</html>
and emits the DTD declaration.
(html:with-html-document (:declare-dtd-version-p :transitional
:language :en
:stream stream)
;; document preamble and body go here
)
The :declare-dtd-version-p argument controls the
DOCTYPE declaration:
:transitional (default) — includes deprecated elements.:strict — no deprecated elements; enables deprecation checking
that signals errors if deprecated attributes are used.:frameset — includes frames.nil — suppresses the DOCTYPE declaration entirely.In the HTML5 package, the simplified <!DOCTYPE
html> is always emitted regardless of this argument, though
the argument is accepted for backward compatibility.
with-document-preambleWraps the <head> section. All metadata, title,
style, and script declarations belong here.
(html:with-document-preamble (:stream stream)
(html:declare-title "Page Title" :stream stream)
(html:declare-link :reference "/cl-http/css/base.css"
:relation "stylesheet" :stream stream)
(html:declare-meta-info "text/html; charset=UTF-8"
:header :content-type :stream stream))
declare-titleDeclares the document title. Every HTML document must have exactly
one title in the preamble. The title can be a string or a function
called with (stream):
(html:declare-title "CL-HTTP Reference Manual" :stream stream)
;; Dynamic title:
(html:declare-title #'(lambda (stream)
(format stream "Status as of ~A"
(http::write-standard-time
(get-universal-time) stream)))
:stream stream)
with-document-style-declaredDeclares an inline CSS style block in the preamble:
(html:with-document-style-declared ((:text :css)
:media :screen
:stream stream)
(write-string "body { margin: 2em; font-family: sans-serif; }" stream)
(fresh-line stream)
(write-string "h1 { color: #003366; }" stream))
This emits:
<style type="text/css" media="screen">
body { margin: 2em; font-family: sans-serif; }
h1 { color: #003366; }
</style>
with-document-bodyWraps the <body> section where all visible
content is placed.
(html:with-document-body (:class "main" :id "content"
:style "margin: 1em;"
:language :en
:stream stream)
;; page content goes here
)
HTML 4.01 adds :events for JavaScript event handlers
(:load, :unload, etc.). Deprecated color
arguments (:background, :foreground,
:link, :visited-link,
:active-link) are still accepted for backward
compatibility but generate deprecation warnings in strict mode.
with-standard-document-bodyA convenience macro that applies the standard CL-HTTP color scheme
from *standard-color-scheme*. Deprecated in HTML 4.01 in
favor of CSS.
(html:with-standard-document-body (:stream stream) ;; body with standard colors applied )
(html:with-html-document (:declare-dtd-version-p :transitional
:language :en :stream stream)
(html:with-document-preamble (:stream stream)
(html:declare-title "Example Page" :stream stream)
(html:declare-meta-info "text/html; charset=UTF-8"
:header :content-type :stream stream))
(html:with-document-body (:stream stream)
(html:with-section-heading ("Welcome" :stream stream)
(html:with-paragraph (:stream stream)
(write-string "This is an example CL-HTTP page." stream)))))
This generates:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>Example Page</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <h1>Welcome</h1> <p>This is an example CL-HTTP page.</p> </body> </html>
with-section-headingCreates a section heading at the specified level (H1 through H6).
The heading level defaults to *section-level*, which
starts at 1 and automatically increments within the body of the
macro, so nested headings get progressively deeper levels:
(html:with-section-heading ("Chapter Title" :stream stream)
;; Inside here, *section-level* is 2
(html:with-paragraph (:stream stream)
(write-string "Introductory text." stream))
(html:with-section-heading ("Section Title" :stream stream)
;; Inside here, *section-level* is 3
(html:with-paragraph (:stream stream)
(write-string "Section content." stream))))
This generates:
<h1>Chapter Title</h1> <p>Introductory text.</p> <h2>Section Title</h2> <p>Section content.</p>
You can override the automatic level with the :level
argument:
(html:with-section-heading ("Explicit H3" :level 3 :stream stream))
HTML 4.01 and HTML5 add standard arguments: :class,
:id, :title, :style,
:language, :direction, and
:events. HTML5 additionally supports
:hidden, :content-editable,
:draggable, :role,
:data-attributes, and :aria-attributes.
with-paragraphWraps content in <p>...</p>:
(html:with-paragraph (:stream stream)
(write-string "A paragraph of text with " stream)
(html:with-rendition (:bold :stream stream)
(write-string "bold" stream))
(write-string " and " stream)
(html:with-rendition (:italic :stream stream)
(write-string "italic" stream))
(write-string " words." stream))
with-renditionApplies a text style to the content within its body. The rendition is specified as a keyword:
| Rendition | HTML Tag | Description |
|---|---|---|
:bold | <b> | Bold text |
:italic | <i> | Italic text |
:teletype | <tt> | Monospaced text |
:code | <code> | Inline computer code (HTML 4.01+) |
:underline | <u> | Underlined text (deprecated in HTML 4.01) |
:strike | <s> | Strike-through text (deprecated in HTML 4.01) |
:large | <big> | Larger text |
:small | <small> | Smaller text |
:superscript | <sup> | Superscript |
:subscript | <sub> | Subscript |
:keyboard | <kbd> | Keyboard input (HTML 4.01+) |
:sample | <samp> | Sample output (HTML 4.01+) |
:variable | <var> | Variable/argument (HTML 4.01+) |
:citation | <cite> | Citation or reference (HTML 4.01+) |
:definition | <dfn> | Defining instance (HTML 4.01+) |
:heading-1 through :heading-6 | <h1>–<h6> | Section headings as rendition |
;; Inline code example:
(html:with-rendition (:code :stream stream)
(write-string "defun" stream))
;; Nested renditions:
(html:with-rendition (:bold :stream stream)
(html:with-rendition (:italic :stream stream)
(write-string "Bold and italic" stream)))
break-line and horizontal-linebreak-line emits <br>.
horizontal-line emits <hr>:
(write-string "Line one." stream) (html:break-line :stream stream) (write-string "Line two." stream) (html:horizontal-line :stream stream)
horizontal-line accepts optional arguments for styling
(HTML 4.01+): :class, :id,
:style, and the deprecated :size,
:width, :alignment, and
:shade.
with-verbatim-textWraps content in <pre>...</pre> for
preformatted text. Whitespace and line breaks are preserved exactly as
written:
(html:with-verbatim-text (:stream stream) (write-string "(defun hello (name)" stream) (terpri stream) (write-string " (format t \"Hello, ~A!\" name))" stream))
This generates:
<pre>(defun hello (name) (format t "Hello, ~A!" name))</pre>
with-anchor-notedCreates a hyperlink. The :reference argument is the
target URL (a string or URL object). The body generates the link
text:
(html:with-anchor-noted (:reference "/cl-http/cl-http.html"
:stream stream)
(write-string "CL-HTTP Home Page" stream))
This generates:
<a href="/cl-http/cl-http.html">CL-HTTP Home Page</a>
Additional arguments:
:local-reference — a fragment identifier for linking within
the same page (emits #name).:tag — a named anchor point
(<a name="...">).:relation — link type to the referenced document.:inverse — reverse relationship.:title — advisory title for the link.The function note-anchor is a non-macro equivalent
that takes the link text as a required string argument:
(html:note-anchor "CL-HTTP Home Page"
:reference "/cl-http/cl-http.html"
:stream stream)
imageInserts an image into the page:
(html:image "/cl-http/icons/power.gif" "CL-HTTP Logo"
:width 134 :height 59
:stream stream)
This generates:
<img src="/cl-http/icons/power.gif" alt="CL-HTTP Logo" width="134" height="59">
The first argument is the image URL and the second is the alternative text (required for accessibility). Additional arguments:
:width, :height — image dimensions in pixels.:alignment — image alignment (deprecated; use CSS).:border — border width in pixels (deprecated; use CSS).:accept-coordinates-at-url — URL for a server-side image map.:client-side-image-map — name of a client-side image map.:description — a long description URL (HTML 4.01).:class, :id, :style,
:events — standard HTML 4.01 attributes.with-enumerationCreates a list environment. The style argument determines the list type:
| Style | HTML Tag | Description |
|---|---|---|
:itemize | <ul> | Unordered (bulleted) list |
:enumerate | <ol> | Ordered (numbered) list |
:definition | <dl> | Definition list (term/description pairs) |
:plain | <ul> | Plain list (no bullets) |
:menu | <menu> | Menu list (deprecated) |
:directory | <dir> | Directory list (deprecated) |
enumerating-itemEmits a single list item within an enumeration:
;; Bulleted list:
(html:with-enumeration (stream :itemize)
(html:enumerating-item (stream)
(write-string "First item" stream))
(html:enumerating-item (stream)
(write-string "Second item" stream))
(html:enumerating-item (stream)
(write-string "Third item" stream)))
This generates:
<ul> <li>First item <li>Second item <li>Third item </ul>
;; Numbered list:
(html:with-enumeration (stream :enumerate)
(html:enumerating-item (stream)
(write-string "Step one" stream))
(html:enumerating-item (stream)
(write-string "Step two" stream)))
;; Definition list:
(html:with-enumeration (stream :definition)
(html:enumerating-item (stream :head "CL-HTTP")
(write-string "A Common Lisp HTTP server." stream))
(html:enumerating-item (stream :head "URL")
(write-string "Uniform Resource Locator." stream)))
This generates:
<dl> <dt>CL-HTTP</dt> <dd>A Common Lisp HTTP server. <dt>URL</dt> <dd>Uniform Resource Locator. </dl>
The :type argument overrides the default bullet or
numbering style. For :enumerate: :capital-letters,
:small-letters, :large-roman,
:small-roman, :arabic (default). For
:itemize: :solid-disc, :circle,
:square.
HTML5 adds the :reversed argument to reverse the
numbering order for ordered lists.
with-tableCreates a table environment. Tables are composed of rows, and rows are composed of cells:
(html:with-table (:border t :stream stream)
(html:with-table-row (:stream stream)
(html:with-table-cell (:header-p t :stream stream)
(write-string "Name" stream))
(html:with-table-cell (:header-p t :stream stream)
(write-string "Version" stream)))
(html:with-table-row (:stream stream)
(html:with-table-cell (:stream stream)
(write-string "CL-HTTP" stream))
(html:with-table-cell (:stream stream)
(write-string "70.226" stream)))
(html:with-table-row (:stream stream)
(html:with-table-cell (:stream stream)
(write-string "SBCL Port" stream))
(html:with-table-cell (:stream stream)
(write-string "1.8.2" stream))))
This generates:
<table border> <tr><th>Name</th><th>Version</th> <tr><td>CL-HTTP</td><td>70.226</td> <tr><td>SBCL Port</td><td>1.8.2</td> </table>
with-table Arguments:border — when non-nil, draws cell borders.:cell-spacing — spacing between cells in pixels.:cell-padding — padding within cells in pixels.:width — table width (integer for pixels, float 0–1 for percentage).:caption — a string or function for the table caption.:caption-alignment — :top or :bottom.:class, :id, :style,
:events — standard HTML 4.01 attributes.with-table-row Arguments:horizontal-alignment — :left, :center, or :right.:vertical-alignment — :top, :middle, or :bottom.with-table-cell Arguments:header-p — when non-nil, renders as <th> instead of <td>.:column-span — number of columns this cell spans.:row-span — number of rows this cell spans.:horizontal-alignment, :vertical-alignment — cell content alignment.:width, :height — cell dimensions.:break-lines-p — when nil, prevents line wrapping.CL-HTTP forms are created with two macros:
with-fillout-form establishes the form environment, and
accept-input creates individual form controls within
it.
with-fillout-formEstablishes a form that submits to a URL. Forms must not be nested (this is enforced at runtime).
(html:with-fillout-form (:post url :stream stream) ;; form controls go here )
Arguments:
:post, :get,
:mail, or :none.:encoding-type — defaults to
'(:multipart :form-data) in HTML 4.01. For simple forms,
'(:application :x-www-form-urlencoded) is also
available.:name — name identifying the form element.:target — frame name for the response document.:events — form-level event handlers (:submit, :reset).HTML5 adds :no-validate (disables form validation) and
:auto-complete (:on or
:off).
accept-inputThe primary interface for form controls. The first argument is a symbol denoting the input type, and the second is the query name (a string) that identifies the value when the form is submitted:
(html:accept-input 'html:string "username"
:default "anonymous"
:size 30
:max-length 100
:stream stream)
| Input Type Symbol | HTML Element | Description |
|---|---|---|
'string | <input type="text"> | Single-line text input |
'password | <input type="password"> | Password input (masked) |
'multi-line-text | <textarea> | Multi-line text area |
'radio-button | <input type="radio"> | Radio button group |
'checkbox | <input type="checkbox"> | Checkbox group |
'select-choices | <select> | Drop-down or multi-select list |
'hidden | <input type="hidden"> | Hidden field |
'file | <input type="file"> | File upload |
'image | <input type="image"> | Clickable image |
'submit-button | <input type="submit"> | Submit button |
'reset-button | <input type="reset"> | Reset button |
The HTML5 package adds these input types:
| Input Type Symbol | HTML Element | Description |
|---|---|---|
'email-field | <input type="email"> | Email address with validation |
'url-field | <input type="url"> | URL with validation |
'number-field | <input type="number"> | Numeric input with min/max/step |
'range-field | <input type="range"> | Slider control |
'date-field | <input type="date"> | Date picker |
'color-field | <input type="color"> | Color picker |
'search-field | <input type="search"> | Search input |
HTML5 input types support additional arguments:
:placeholder, :required,
:auto-focus, :pattern (regex
validation), :min, :max,
:step, and :multiple (for email-field).
(html:with-fillout-form (:post url :stream stream)
;; Text field
(html:accept-input 'html:string "name"
:default "Your Name" :size 40
:label "Name: " :stream stream)
(html:break-line :stream stream)
;; Password
(html:accept-input 'html:password "pass"
:size 20 :max-length 32
:label "Password: " :stream stream)
(html:break-line :stream stream)
;; Radio buttons
(html:accept-input 'html:radio-button "color"
:choices '("Red" "Green" "Blue")
:default "Green"
:stream stream)
(html:break-line :stream stream)
;; Checkboxes
(html:accept-input 'html:checkbox "features"
:choices '("HTTP/1.1" "HTTP/2" "SSL/TLS")
:default "HTTP/1.1"
:stream stream)
(html:break-line :stream stream)
;; Select menu
(html:accept-input 'html:select-choices "port"
:choices '(("LispWorks" . "lw")
("SBCL" . "sbcl")
("Genera" . "genera"))
:default "sbcl"
:stream stream)
(html:break-line :stream stream)
;; Multi-line text
(html:accept-input 'html:multi-line-text "comments"
:rows 5 :columns 60
:default "Enter comments here..."
:stream stream)
(html:break-line :stream stream)
;; Hidden field
(html:accept-input 'html:hidden "session-id"
:default session-token
:stream stream)
;; Submit and Reset
(html:accept-input 'html:submit-button "action"
:default "Submit" :stream stream)
(html:accept-input 'html:reset-button "reset"
:default "Clear" :stream stream))
The 'file input type produces an
<input type="file"> control and requires the form's
:encoding-type to be '(:multipart :form-data)
(the HTML 4.01 default). When the form is submitted, CL-HTTP's
multipart parser saves each uploaded file to a temporary pathname under
http:*file-upload-default-directory* and passes the
pathname as the field value to the form's response function, with
:upload-filename, :content-type, and
:copy-mode in the query baggage.
CL-HTTP's accept-input 'html:file ... writes the field's
NAME attribute as an armor-plated base64 pack of
(query-name directory-index) so the server can route uploads
to per-form upload directories. Forms not generated by
accept-input -- hand-written HTML, browser file inputs from
arbitrary frameworks, curl -F, third-party form builders --
send the field NAME verbatim. The parser accepts both forms: if the
NAME decodes to a valid armor-plated baggage list it is used to look up
the per-form upload directory; otherwise the NAME is taken verbatim and
the file is saved under
http:*file-upload-default-directory*. This tolerance means
generic HTML forms work without modification.
The position of the file part within the multipart body is
irrelevant: file at the first position, in the middle, just before the
submit button, or last all parse identically. Both text and binary file
parts are supported; binary uploads (Content-Type:
application/octet-stream) preserve content byte-for-byte,
while text uploads apply local-charset CRLF translation.
All input types accept these keyword arguments:
:default — default value.:disabled — disables the control (boolean).:read-only — makes the control uneditable.:label — provides a label for the control.:tab-index — position in the tab order (integer).:access-key — keyboard shortcut character.:preamble — a function or string written before the input.:class, :id, :style,
:title, :events — standard HTML 4.01 attributes.:stream — output stream.with-scriptEmits a <script> element for client-side
scripting. Usually placed in the document preamble or at the end of
the body:
(html:with-document-preamble (:stream stream)
(html:declare-title "Interactive Page" :stream stream)
(html:with-script ((:text :javascript) :stream stream)
(write-string "function greet(name) {" stream)
(fresh-line stream)
(write-string " alert('Hello, ' + name + '!');" stream)
(fresh-line stream)
(write-string "}" stream)))
This generates:
<script type="text/javascript">
function greet(name) {
alert('Hello, ' + name + '!');
}
</script>
Arguments:
(:text :javascript).:script-location — a URI for an external script file.
When provided, the body is ignored and a src attribute
is emitted instead.:no-content — maps to the HTML defer attribute.:charset — character encoding for the script.:hide-javascript — wraps the script in HTML comments for old browsers.HTML5 adds :async (asynchronous loading),
:integrity (subresource integrity hash),
:cross-origin (:anonymous or
:use-credentials), and :no-module.
define-scriptdefine-script registers a named, reusable script
object. It separates the script definition from its invocation,
enabling the same script to be used across multiple pages:
(html:define-script check-bounds (java-script)
:documentation "Checks integer bounds on a form field."
:caller ((script stream min max)
(html:fast-format stream
"\"if (!Check_Bounds(this.value, ~D, ~D))~
~% {this.focus();this.select();}\"" min max))
:script ((script stream)
(html:fast-format stream
"function Check_Bounds(v, min, max) {~
~% var n = parseInt(v);~
~% if (isNaN(n) || n < min || n > max) {~
~% alert('Value must be between ' + min + ' and ' + max);~
~% return false;~
~% }~
~% return true;~
~%}")))
The :script clause defines how to write the script
text. The :caller clause defines how to write a call to
the script from an event handler. Use declare-script in
the preamble and event-caller in form controls:
;; In the preamble:
(html:with-document-preamble (:stream stream)
(html:declare-script check-bounds stream))
;; In the form body:
(html:with-event-handlers
(events
(:java-script
:new-value (html:event-caller check-bounds 1 100)))
(html:accept-input 'html:string "quantity"
:events events :stream stream))
with-event-handlersBinds a variable to a set of client-side event handlers for use with form controls and other elements:
(html:with-event-handlers
(events
(:java-script
:mouse-over "this.style.color='red'"
:mouse-out "this.style.color='black'"))
(html:with-anchor-noted (:reference "/help" :stream stream)
(html:note-anchor "Help" :reference "/help"
:events events :stream stream)))
Events are specified as keyword/command pairs. The event keywords correspond to HTML 4.01 intrinsic events:
| Event Keyword | HTML Attribute | Description |
|---|---|---|
:mouse-click | onclick | Element clicked |
:mouse-double-click | ondblclick | Element double-clicked |
:mouse-over | onmouseover | Pointer enters element |
:mouse-out | onmouseout | Pointer leaves element |
:mouse-down | onmousedown | Pointer button pressed |
:mouse-up | onmouseup | Pointer button released |
:mouse-move | onmousemove | Pointer moved over element |
:key-press | onkeypress | Key pressed and released |
:key-down | onkeydown | Key pressed down |
:key-up | onkeyup | Key released |
:input-focus | onfocus | Element receives focus |
:input-defocus | onblur | Element loses focus |
:new-value | onchange | Control value changed |
:select | onselect | Text selected |
:submit | onsubmit | Form submitted |
:reset | onreset | Form reset |
:load | onload | Document/frameset loaded |
:unload | onunload | Document/frameset unloaded |
CL-HTTP's HTML generation packages form a progressive tower. Each version inherits all macros from the previous version and adds new capabilities. Below is a summary of what each version contributes.
html2)The foundation. Defines:
>, <, &, ")with-html-document, with-document-preamble, with-document-bodywith-anchor-noted, note-anchorwith-section-headingwith-verbatim-text:bold, :italic, :teletype, :heading-1 through :heading-6with-emphasis (:emphasis, :strong, :address, :quotation, :code, :keyboard, :variable, :citation, :sample)with-enumeration, enumerating-itemwith-comment, commentwith-fillout-form, accept-input (basic types)*output-stream* conventionhtml3.2)Extends HTML2 with:
with-table, with-table-row, with-table-cellwith-client-image-map, image-map-areawith-font (face, size, color):large, :small, :strike, :subscript, :superscript, :underlinewith-standard-document-body:type, :start)with-divisionnetscape1.1, netscape2.0, netscape3.0, netscape4.0)CL-HTTP includes packages that track Netscape browser extensions, which predated and influenced the HTML standards:
<body>,
line break clearing, horizontal rule sizing, image alignment extensions,
blinking text.with-document-frameset),
JavaScript event support on forms, file upload, divisions with alignment,
targets for forms and anchors.with-font),
multi-column layout, spacer elements, embedded objects.with-layer),
additional event handlers.These packages are historical. New code should use HTML 4.01 or HTML5 macros, which subsume all the useful Netscape extensions.
html4.0)The major step forward. Adds:
:strict, :transitional, :frameset with deprecation checkingwith-document-style-declared, inline :style on all elements:class, :id, :title, :style, :language, :directionwith-event-handlers, 18 intrinsic eventswith-script, define-script, declare-script, event-caller:code, :keyboard, :sample, :variable, :citation, :definition, :abbreviation, :acronymwith-form-field-set), buttons (with-form-button), :label on all input types, :disabled, :read-only, :tab-index, :access-keywith-table-column-group), table head/body/foot sectionswith-inline-framewith-object, declare-object-parameterxhtml1.0)XML-compatible reformulation of HTML 4.01. Changes:
<?xml version="1.0"?>)<br />, <hr />, <img ... />)disabled="disabled" instead of just disabled)*xhtml-generation* flag that inner macros checkhtml5)The current standard. Extends HTML 4.01 (not XHTML) with:
<!DOCTYPE html>with-header, with-footer, with-navigation, with-article, with-section, with-aside, with-main-content, with-figure, with-figure-captionwith-details/with-summary, with-dialogwith-mark, with-time-elementwith-audio, with-video, with-media-source:hidden, :content-editable, :draggable, :spell-check, :role, :data-attributes, :translate, :inert, :nonce, :aria-attributesemail-field, url-field, number-field, range-field, date-field, color-field, search-field:placeholder, :required, :auto-focus, :pattern, :no-validate:async, :integrity (SRI), :cross-origin:reversed on with-enumerationHTML5 deliberately excludes client-side-only features that have no meaningful server-side generation semantics: Popover API, inputmode, enterkeyhint, autocapitalize, Custom Elements, Shadow DOM, and Microdata.
The following example brings together document structure, headings, tables, lists, forms, links, and images in a single response function:
(http:export-url #u"/cl-http/manual-example.html"
:html-computed
:response-function
#'(lambda (url stream)
(declare (ignore url))
(http:with-successful-response (stream :html)
(html:with-html-document (:declare-dtd-version-p :transitional
:language :en :stream stream)
(html:with-document-preamble (:stream stream)
(html:declare-title "CL-HTTP Manual Example" :stream stream))
(html:with-document-body (:stream stream)
;; Page heading with a logo
(html:image "/cl-http/icons/power.gif" "CL-HTTP"
:width 134 :height 59 :stream stream)
(html:with-section-heading ("CL-HTTP Platforms" :stream stream)
;; Introductory paragraph
(html:with-paragraph (:stream stream)
(write-string "CL-HTTP runs on " stream)
(html:with-rendition (:bold :stream stream)
(write-string "multiple Lisp implementations" stream))
(write-string ". See the " stream)
(html:with-anchor-noted (:reference "/cl-http/cl-http.html"
:stream stream)
(write-string "home page" stream))
(write-string " for details." stream))
;; Feature table
(html:with-table (:border t :stream stream)
(html:with-table-row (:stream stream)
(html:with-table-cell (:header-p t :stream stream)
(write-string "Platform" stream))
(html:with-table-cell (:header-p t :stream stream)
(write-string "HTTP/2" stream))
(html:with-table-cell (:header-p t :stream stream)
(write-string "SSL/TLS" stream)))
(html:with-table-row (:stream stream)
(html:with-table-cell (:stream stream)
(write-string "LispWorks" stream))
(html:with-table-cell (:stream stream)
(write-string "Yes" stream))
(html:with-table-cell (:stream stream)
(write-string "OpenSSL" stream)))
(html:with-table-row (:stream stream)
(html:with-table-cell (:stream stream)
(write-string "SBCL" stream))
(html:with-table-cell (:stream stream)
(write-string "Yes" stream))
(html:with-table-cell (:stream stream)
(write-string "pure-tls" stream))))
;; Bulleted feature list
(html:with-section-heading ("Key Features" :stream stream)
(html:with-enumeration (stream :itemize)
(html:enumerating-item (stream)
(write-string "Package-based portability" stream))
(html:enumerating-item (stream)
(write-string "HTML generation macros" stream))
(html:enumerating-item (stream)
(write-string "W3P presentation system" stream))))))))))
Table of Contents | Previous: WebSockets | Next: Authentication