Href attribute

When putting a href attribute into an anchor element, is it necessary to put quotation marks around the URL?

From a standpoint of best practice, yes, always write quotes on attribute values. The only exception to this is when the attribute is a boolean.

<input type="checkbox" checked>
1 Like

Thanks! I wasn’t sure because when I hit “run,” it did the same thing with or without quotation marks.

1 Like

HTML5 when served as ‘text/html’ follows HTML 4 syntax rules (for the most part) so quotes are optional. However, this can lead to problems that are hard to track down, hence the best practice of always writing quotes on attribute values.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.