Href attribute


#1

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


#2

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>

#3

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


#4

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.


#5

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