homepage Welcome to WebmasterWorld Guest from 54.226.136.179
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
inline css attributes - with " marks or without?
santapaws

5+ Year Member



 
Msg#: 4321494 posted 10:42 am on Jun 3, 2011 (gmt 0)

in my html4/loose pages i always thought itw as correct specify class with an apostrophe such as class="this". I now see that minified code removes the apostrophe and leaves it as class=this. Same thing for height and width height=45 rather than height="45". If the apostrophe is not required why do we use it? it is ok to remove this and minify html site wide. perhaps it was just an old browser issue?

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4321494 posted 5:01 pm on Jun 3, 2011 (gmt 0)

In XML (and likely XHTML?) quoting is required for valid parsing.

From the spec [w3.org],

In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.


So really, I think, it's the browser that's allowing you to get away with it by parsing them when they aren't quoted. As a test, try "minifying" a page with

name='Big "Bill" Coder'

It will likely leave those quotes in.

Minifying code removes the quotes to reduce the size of the document, it adds a lot of bytes when quoted. :-) I prefer to collect savings elsewhere.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved