HTML Coding - Is there a benefit disadvantage to using "quotes" or "apostrophes"? [duplicate]

StackOverflow https://stackoverflow.com/questions/13937870

  •  10-12-2021
  •  | 
  •  

質問

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?

役に立ちましたか?

解決

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.

他のヒント

It's a personal preference.

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top