How to properly escape quotes inside HTML attributes?

Spread the love

Sometimes, we want to properly escape quotes inside HTML attributes.

In this article, we’ll look at how to properly escape quotes inside HTML attributes.

How to properly escape quotes inside HTML attributes?

To properly escape quotes inside HTML attributes, we use ".

For instance, we write

<select>
  <option value='&quot;asd'>Test</option>
</select>

to add a select element with an option element with the value attribute set to &quot;asd.

Then &quot will be rendered as ".

Conclusion

To properly escape quotes inside HTML attributes, we use &quot;.

Leave a Reply

Your email address will not be published.