Create HTML tags — builder

v1.7.3|Source: R/tags.R


Create an R object that represents an HTML tag. For convenience, common HTML tags (e.g., <div>) can be created by calling for their tag name directly (e.g., div()). To create less common HTML5 (or SVG) tags (e.g., <article>), use the tags list collection (e.g., tags$article()). To create other non HTML/SVG tags, use the lower-level tag() constructor.


p(..., .noWS = NULL, .renderHook = NULL)

h1(..., .noWS = NULL, .renderHook = NULL)

h2(..., .noWS = NULL, .renderHook = NULL)

h3(..., .noWS = NULL, .renderHook = NULL)

h4(..., .noWS = NULL, .renderHook = NULL)

h5(..., .noWS = NULL, .renderHook = NULL)

h6(..., .noWS = NULL, .renderHook = NULL)

a(..., .noWS = NULL, .renderHook = NULL)

br(..., .noWS = NULL, .renderHook = NULL)

div(..., .noWS = NULL, .renderHook = NULL)

span(..., .noWS = NULL, .renderHook = NULL)

pre(..., .noWS = NULL, .renderHook = NULL)

code(..., .noWS = NULL, .renderHook = NULL)

img(..., .noWS = NULL, .renderHook = NULL)

strong(..., .noWS = NULL, .renderHook = NULL)

em(..., .noWS = NULL, .renderHook = NULL)

hr(..., .noWS = NULL, .renderHook = NULL)

tag(`_tag_name`, varArgs, .noWS = NULL, .renderHook = NULL)



Tag attributes (named arguments) and children (unnamed arguments). A named argument with an NA value is rendered as a boolean attributes (see example). Children may include any combination of:

  • Other tags objects

  • HTML() strings

  • htmlDependency()s

  • Single-element atomic vectors

  • list()s containing any combination of the above


Character vector used to omit some of the whitespace that would normally be written around this tag. Valid options include before, after, outside, after-begin, and before-end. Any number of these options can be specified.


A function (or list of functions) to call when the tag is rendered. This function should have at least one argument (the tag) and return anything that can be converted into tags via as.tags(). Additional hooks may also be added to a particular tag via tagAddRenderHook().


A character string to use for the tag name.


List of tag attributes and children.


A list() with a shiny.tag class that can be converted into an HTML string via as.character() and saved to a file with save_html().

See also


    tags$title('My first page')
    h1('My first heading'),
    p('My first paragraph, with some ', strong('bold'), ' text.'),
      id = 'myDiv', class = 'simpleDiv',
      'Here is a div with some attributes.'

# html5 <audio> with boolean control attribute
  controls = NA,
    src = "myfile.wav",
    type = "audio/wav"

# suppress the whitespace between tags
  tags$strong("I'm strong", .noWS="outside")