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.

tags

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)

Arguments

...

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:

.noWS

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.

.renderHook

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().

_tag_name

A character string to use for the tag name.

varArgs

List of tag attributes and children.

Value

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().

Examples

tags$html(
  tags$head(
    tags$title('My first page')
  ),
  tags$body(
    h1('My first heading'),
    p('My first paragraph, with some ', strong('bold'), ' text.'),
    div(
      id = 'myDiv', class = 'simpleDiv',
      'Here is a div with some attributes.'
     )
  )
)
#> <html>
#>   <body>
#>     <h1>My first heading</h1>
#>     <p>
#>       My first paragraph, with some 
#>       <strong>bold</strong>
#>        text.
#>     </p>
#>     <div id="myDiv" class="simpleDiv">Here is a div with some attributes.</div>
#>   </body>
#> </html>

# html5 <audio> with boolean control attribute
# https://www.w3.org/TR/html5/infrastructure.html#sec-boolean-attributes
tags$audio(
  controls = NA,
  tags$source(
    src = "myfile.wav",
    type = "audio/wav"
  )
)
#> <audio controls>
#>   <source src="myfile.wav" type="audio/wav"/>
#> </audio>

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