0

Possible Duplicate:
Single vs Double quotes (' vs ")

I just purchased an HTML template built on Twitter Bootstrap. Parts of the template are coded with class='navbar' rather than class="navbar" (notice the apostrophes rather than quotation marks for the class attribute).

Is there a benefit or disadvantage to using apostrophes over quotation marks?

Community
  • 1
  • 1
adamdehaven
  • 5,890
  • 10
  • 61
  • 84
  • 1
    The single apostrophes obviously take up less space. (I had a teacher in elementary school that insisted we save our Oregon Trail characters in all lowercase, as it would take up less space on the disk).. – Mike Christensen Dec 18 '12 at 17:02

2 Answers2

4

Nope. You're entirely free to use either.

One of the reasons both exist is so it's less work to work with them in javascript.

var lumpOfHTML="<a href='http://google.com'>Link 1</a>";
var anotherLumpOfHTML='<a href="http://google.com">Link 1</a>';

Both of these will do the same thing.

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
  • I guess my issue is that some of the template uses quotes as in `href="../index.html"` but the classes and id attributes use apostrophes as in `class='navbar'`. Seems frustrating so far. Any idea how to streamline this? (I use Dreamweaver CS6, and the site will end up being PHP) – adamdehaven Dec 18 '12 at 17:03
1

It's a personal preference.

BTW: In HTML5 is it allowed to not use quotes eg. class=navbar if te value is 1 word

beardhatcode
  • 4,533
  • 1
  • 16
  • 29
  • do you have a source for that? I'm not sure I've seen that before. – Tuanderful Dec 18 '12 at 17:06
  • http://www.w3.org/TR/html-markup/syntax.html#syntax-attributes says: an unquoted attribute value is specified by providing the following parts in exactly the following order: an attribute name; zero or more space characters; a single "=" character; zero or more space characters; an attribute value ( @Tuanderful ) – beardhatcode Dec 18 '12 at 17:20
  • Not just HTML5. All versions of HTML except the XHTML variants have allowed that. – Alohci Dec 18 '12 at 17:46
  • Really @Alohci ? I know it would work in the browser, but this would make for "invalid HTML" (That what I thought at least) – beardhatcode Dec 18 '12 at 18:23
  • ah, i misread your answer as "in HTML5, it is not allowed to use quotes if the value is one word" – Tuanderful Dec 18 '12 at 18:34
  • 1
    @gar_onn - It's perfectly valid. For example, see the [HTML 2.0 spec](http://www.rfc-editor.org/rfc/rfc1866.txt), page 14, sectiop 3.2.4. Attributes, second bullet point. – Alohci Dec 18 '12 at 20:15