Is there any difference in using single quotes or double quotes in HTML? | SoloLearn: Learn to code for FREE!

+2

Is there any difference in using single quotes or double quotes in HTML?

Following code works properly if single quotes are used in document.getElementById('demo') But does not work for double quotes document.getElementById("demo") https://code.sololearn.com/W3AOPsfk4TH4/?ref=app

5/16/2020 3:17:32 PM

Anutosh Kumar

3 Answers

New Answer

+3

That bug happens because the statement in the onclick attribute is surrounded by double quotes so if you put another double quote inside it, it won't consider it as part of the string. Same with putting single quotes on both of them. Also, there isn't any difference in single quotes and double quotes in HTML.

+3

you can use both single and double quotes in javascript code. you can use use both quotes in html code, but it is recommended through convention to use double quotes for attribute values

+2

I have got my error thanks for the answer