Appearance html code in input value

297 views Asked by At

I want to do such a thing

<input type="text"  value="<a href="abc.html"><img src="abc.jpg"></a>">

but not appearance this (

<a href="abc.html"><img src="abc.jpg"></a>

) code as text. plz help me.

3

There are 3 answers

1
Barmar On

Use different types of quotes for the inner quoting:

<input type="text"  value="<a href='abc.html'><img src='abc.jpg'></a>">
0
Quentin On

For an attribute value that is delimited by " characters to contain a " character as data, it must be represented by a character reference: &quot;

1
jshawl On

You should use :

<input type='image' src='/path/to/img.jpg'>

Codepen