+ 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

16th May 2020, 3:17 PM
Anutosh Kumar
Anutosh Kumar - avatar
3 Answers
+ 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.
16th May 2020, 3:24 PM
CeePlusPlus
CeePlusPlus - avatar
+ 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
16th May 2020, 3:24 PM
Sebastian Pacurar
Sebastian Pacurar - avatar
+ 2
I have got my error thanks for the answer
16th May 2020, 3:29 PM
Anutosh Kumar
Anutosh Kumar - avatar