Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does google.com not use double quotes around the values of some HTML attributes?

Tags:

html

I was looking at the sourcecode of google.com (the web-rendered version ofc. ;-)) and I noticed that they don't always use double quotes around the values of some HTML attributes, like:

<a onclick=gbar.qs(this) class=gbmt id=gb_10 href="http://books.google.com/bkshp?hl=en&tab=wp&authuser=0" onclick="gbar.logger.il(1,{t:10})">Books</a>

What's the advantage of coding your site like this?

source: www.google.com

like image 350
Wouter Dorgelo Avatar asked Dec 01 '11 22:12

Wouter Dorgelo


People also ask

Do HTML attributes need double quotes?

The HTML specification says: Attributes are placed inside the start tag, and consist of a name and a value, separated by an = character. The attribute value can remain unquoted if it doesn't contain spaces or any of " ' ` = < or > . Otherwise, it has to be quoted using either single or double quotes.

Can you allow the value of an HTML attribute to contain a double quote symbol?

The double quote ( " ) has special meaning inside a HTML attribute. If you want to put it into an attribute value, you must (this is not a true must but a good rule of thumb. It's a must if you use attributes delimited by double-quotes as you do in your question) write it as its entity &quot; .

Do you need quotes for HTML attributes?

The HTML standard does not require quotes around attribute values. However, W3C recommends quotes in HTML, and demands quotes for stricter document types like XHTML.


2 Answers

Because HTML doesn't care. Quotes are not required. In the case of a boolean attribute, it doesn't even need a value either at times (ex. disabled vs. disabled="disabled"). Only XML (and XHTML served with an XML mimetype) cares about syntax in this way because XML spec defines these are required.

like image 162
Kevin Peno Avatar answered Oct 06 '22 09:10

Kevin Peno


I believe this is done to minimize the size of HTML of the page as much as possible. Because when you are serving as many pages as google every byte counts. I remember quite a while ago there was an article about it. They also don't close a lot of the opening tags and some other stuff.

EDIT: Found the article from 2 years ago: http://blog.errorhelp.com/2009/06/27/the-highest-traffic-site-in-the-world-doesnt-close-its-html-tags/

like image 20
Strelok Avatar answered Oct 06 '22 07:10

Strelok