mikhl Posted August 3, 2012 Share Posted August 3, 2012 Hello. This is just a general curiosity question. I am just wondering about peoples preferences with the use of double quotes in HTML5. In XHTML and HTML5 the following is valid: <div id="wrapper"> <div class="someClass"> <p class="important">Some Content Here!</p> </div> </div> However I hear that in HTML5 you can also choose to leave the double quotes out: <div id=wrapper> <div class=someClass> <p class=important>Some Content Here!</p> </div> </div> I think it makes sense that they wouldn't be required. However, for the moment I am still using them to ensure there are no compatibility issues with any older browsers. What do you think about this, do you think its a good idea? What approach do you think we should be using now if we are coding HTML5 pages? Quote Link to comment https://forums.phpfreaks.com/topic/266630-html5-and-double-quotes/ Share on other sites More sharing options...
ManiacDan Posted August 3, 2012 Share Posted August 3, 2012 While quotes are ostensibly optional for spaceless attribute values in HTML5, quotes are not optional for XHTML, and some parsers/browsers will not like unquoted strings. There's no reason that I can see to not just "do it right" and quote all your attributes. Quote Link to comment https://forums.phpfreaks.com/topic/266630-html5-and-double-quotes/#findComment-1366568 Share on other sites More sharing options...
Jessica Posted August 3, 2012 Share Posted August 3, 2012 A div can have more than one class. without the quotes, how would it work? <div class=someClass otherclass thirdclass {metadata:this is some data}> Quote Link to comment https://forums.phpfreaks.com/topic/266630-html5-and-double-quotes/#findComment-1366587 Share on other sites More sharing options...
ManiacDan Posted August 3, 2012 Share Posted August 3, 2012 The quotes are only optional when there's no spaces in the string that would otherwise be quoted. Quote Link to comment https://forums.phpfreaks.com/topic/266630-html5-and-double-quotes/#findComment-1366615 Share on other sites More sharing options...
Jessica Posted August 3, 2012 Share Posted August 3, 2012 Yeah seems like there's no reason to leave them out. It would only cause problems down the road Quote Link to comment https://forums.phpfreaks.com/topic/266630-html5-and-double-quotes/#findComment-1366622 Share on other sites More sharing options...
mikhl Posted August 3, 2012 Author Share Posted August 3, 2012 Hmm. I agree, if your going to use quotes for multiple classes then you may as well keep to the convention and use them constantly. Seems like a better practice. Kind of like closing the <p> tag in my opinion is a must!! Quote Link to comment https://forums.phpfreaks.com/topic/266630-html5-and-double-quotes/#findComment-1366668 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.