<p>Of course, there are a whole range of possible errors relating to document validity, but my immediate stumbling block occurs when changing a paragraph (<code>p</code>) into an <code>address</code> element. My current method is (more-or-less):</p>

<pre><code>var p = $('p#test');
p.replaceWith('&lt;address&gt;' + p.html() + '&lt;/address&gt;');
</code></pre>

<p>but that fails for this specific case; it works perfectly for p -> blockquote or h2 -> h3. Firebug suggests that a self-closing element (<code>&lt;address/&gt;</code>) has been added to the document, for some reason.</p>

<p>Can anyone spot the bug or suggest an alternative method?</p>

You'll could use a placeholder around the title:
```
<span id="demo"><h1>Title</h1></span>
```
Then use JavaScript DOM to create new values for the innerHTML property.
```
<script type="javascript">

setTitle = function(id, tag, title) {
  var container = document.getElementById(id);
  container.innerHTML = '<' + tag + '>' + title + '</' + tag + '>';
}

setTitle('demo', 'h1', 'My Title');

</script>
```