<span id='a'><img src='b.gif' /></span>
<script>
alert(document.getElementById('a').innerHTML);
</script>
The output is: <img src="b.gif" />
‘b.gif’ is being shown as “b.gif”
Viewing the source code in FireBug also shows double quotes. Why is this happening?
Double quotes are the standard for attributes, single quote are obviously acceptable though.The
innerHTMLis the processed set of tags, so the browsers will set the attributes with double quotes as standardAs has been pointed out, there is no “standard” when it comes to double or single quotes on attributes.
My guess would be that browsers use double quotes by default, and therefore when you request the
innerHTML, it will format them as such. If I am incorrect, I will remove this answer immediately