Is there any difference between the following code blocks?
<iframe src="http://example.com" width=100%></iframe>
<iframe src=http://example.com width="100%"></iframe>
I've tried both and both seem to work, but I'm asking just in case there's something I need to be careful with?
There is no practical difference except
Otherwise, the quotation marks are really needed only if the attribute value contains a space, a line break, an Ascii quotation mark ("), an Ascii apostrophe ('), a grave accent (`), an equals sign (=), a less than sign (<), or a greater than sign (>). So style = width:20em
would work (though it might be seen as somewhat obscure), whereas style = width: 20em
would not – due to the space, you would need to write style = "width: 20em"
.
Many people always write quotation marks around all attribute values, for simplicity. Others think that quotation marks make the code a bit messy, so they omit them when possible.
Quite independently of this, src="www.example.com"
means a relative URL reference, not what people expect to mean. You probably meant src="http://www.example.com"
.