html_tag: Build an HTML element

View source: R/html.R

html_tagR Documentation

Build an HTML element

Description

Children given as ... are escaped unless marked with html_raw() or produced by another ⁠html_*⁠ constructor. Lists are flattened, so children can be built with lapply(), and NULL children are dropped.

Usage

html_tag(name, ..., class = NULL, style = NULL, id = NULL)

Arguments

name

Character: Element name, e.g. "div". Must be a single valid element name: a letter followed by letters, digits, or hyphens.

...

Children: Character, numbers, rtemis_html objects, or lists of those.

class

Optional Character: class attribute. Must be NULL or a single string; collapse multiple classes yourself, e.g. paste(x, collapse = " ").

style

Optional Character: style attribute. Must be NULL or a single string.

id

Optional Character: id attribute. Must be NULL or a single string.

Details

A tag holding a single text child renders on one line; anything else renders as an indented block, and a child's own line breaks are indented with it, so indentation always tracks nesting depth.

Value

Character of class rtemis_html_element and rtemis_html.

Author(s)

EDG

Examples

html_tag("section", "Body text", class = "intro")
html_tag("ul", lapply(c("one", "two"), html_li))

rtemis.core documentation built on Sept. 20, 2026, 9:06 a.m.