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