Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have quotation marks in HTML input values [duplicate]

Tags:

html

escaping

I have the following problem - from the server side I get a string like 'hoschi"brother'.

I want to put this string into a <input value"MYSTRING" />. This results in something like <input value"hoschi" brother" /> which obviously does not work.

Is there a workarounds for this?

Does escaping the " character with &quot; work within the value tag?

like image 379
tobi Avatar asked Oct 20 '09 10:10

tobi


People also ask

How do you keep quotes in HTML?

The HTML <q> tag defines a short quotation. Browsers normally insert quotation marks around the quotation.

How do you display double quotes?

For printing double quotes(” “), using print() in C we make use of ” \” ” backslash followed by double quote format specifier.

Can you allow the value of an HTML attribute to contain a double quote symbol?

No, there is not. The double quote ( " ) has special meaning inside a HTML attribute. If you want to put it into an attribute value, you must (this is not a true must but a good rule of thumb. It's a must if you use attributes delimited by double-quotes as you do in your question) write it as its entity &quot; .


1 Answers

Yes, using &quot; works:

<input type="text" name="last_name" value="&quot;My quote!&quot;" /> 
like image 144
Dominic Rodger Avatar answered Sep 24 '22 05:09

Dominic Rodger