Search code examples
htmlquotes

HTML attribute with/without quotes


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?


Solution

  • It is all about the true validity of HTML markup. It's for what W3C (WWW Consortium) work for. Many things might work in HTML but they have to be validated in order to be more carefully recognized by the web browser. You can even omit the <html> and </html> tags at the start and end, but it is not recommended at all, nobody does it and it is considered as a 'bad code'.

    Therefore, it is more valid to put them in quotes.