Notaras Notaras - 8 days ago 5
HTML Question

Why does Chrome add extra html to my page?

I have a snippet of code that looks like this in my html document:

<p style="[some stype]">
<span style="[some_style]">Request ID : </span>
<a name="request_id" />
</p>
<p>....</p>


When i open it up in Chrome and inspect the
<p>
element, this is what is shown:

<p style="[some stype]">
<span style="[some_style]">Request ID : </span>
<a name="request_id" />
</p>
<a name="request_id">
</a>
<p>....</p>


It has in fact, added another identical
<a>
tag under the first p.

However, if i select 'view page source', the HTML code shown is identical to that in my file.
Why would Chrome add the extra
<a>
into the HTML?

Note: I am aware that
name
is an invalid attribute for an
<a>
however this is how bookmarks are represented in HTML when converting from docx to this format so im sticking with it.

Answer

<a> is not a self-closing tag. It’s invalid to use <a /> (instead of <a></a>) in HTML (and inadvisable in XHTML for compatibility).

<p style="[some style]">
    <span style="[some_style]">Request ID : </span>
    <a name="request_id"></a>
</p>
Comments