1

Topic: HTML to XHTML: end tag for empty element

Greetings,

I am trying to convert HTML code to XHTML but i can not transform <input/> to <input></input>. Any help?

2

Re: HTML to XHTML: end tag for empty element

Empty elements in XHTML, like 'input', either have an end tag ('</input>') or their start tags end with ' />'. The latter is recommended (http://www.w3.org/TR/xhtml1/#guidelines), and htmLawed uses such a rule.

If you really need end tags for all empty elements, you can further modify the htmlawed output, e.g., with:

$out = htmLawed($in, ...);
$out = preg_replace('`<([a-z]+)([^>]*?) />`', '<\\1\\2></\\1>', $out);