I’ve always thought html requires quotation marks in his properties:
<div class="service_definition"> or <div class='service_definition'>
But recently i noticed that the w3 validator doesn’t recognize the following as an error:
<div class=service_definition>
So is it all right if i omit the quotation marks? Or are there any restrictions?
Always use quotation marks.
I don’t believe that HTML properties without quotation marks are classed as Invalid HTML, but they will potentially cause you problems later on down the line.
Source: http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.2
I think they’re a great way of clearly defining when an attribute value starts and finishes.
Take for example the
classattribute which can have multiple classes seperated by spaces:This clearly shows the browser that my classes are
classaandclassb, with an element id of123.Take away the quotation marks and we’ve got:
A browser could now interpret this as 3 classes, with no id.
classa,classbandid=123.Or it may even interpret it as 3 attributes.
class="classa",classb=""andid="123"(Even stackoverflow’s syntax styling is struggling with this one!)