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

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

  •  10-12-2021
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

It's a personal preference.

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top