Skip to content
scribu edited this page Feb 24, 2012 · 6 revisions

html() is a function you can use for generating HTML.

Note that the attributes are passed through esc_attr(), but the content is not escaped in any way.

Basic

  • Input: html( 'p', 'Hello world!' );
  • Output: <p>Hello world!</p>

Attributes

  • Input: html( 'a', array( 'href' => 'http://example.com' ), 'A link' );
  • Output: <a href="http://example.com">A link</a>

Boolean Attributes

  • Input: html( 'input', array( 'type' => 'checkbox', 'name' => 'foo', 'checked' => true ) );
  • Output: <input type="checkbox" name="foo" checked />

Multiple arguments as content

Input:

html( 'ul',
  html( 'li', 'a' ),
  html( 'li', 'b' )
);

Output: <ul><li>a</li><li>b</li></ul>

Clone this wiki locally