Skip to content

HTML Invalid Attribute Value

Quick summary

You wrote value="say "hi"" — the inner quote closes the attribute early and the rest becomes invalid markup.

Why this happens

  • Unescaped double quote inside a double-quoted attribute

  • Missing quotes around a value with spaces

  • Boolean attribute given a value that the parser misreads

Minimal example

✗ Broken code
<input value="say "hi"" /> <!-- attribute closes early -->
✓ Fixed code
<input value='say "hi"' /> <!-- single quotes outside -->

The inner double quote closes the attribute early, corrupting the markup. Using single quotes for the attribute lets the inner double quotes stay literal.

How to diagnose

  • Inspect the DOM — the attribute value is truncated or wrong

  • Run the W3C validator to find attribute syntax errors

  • View the page source and locate the broken attribute

How to fix

  • Escape inner quotes with &quot; or use single quotes for the attribute

  • Always quote attribute values containing spaces

  • Use a templating engine that auto-escapes attributes

How to prevent

  • Use a templating framework that escapes attribute values

  • Validate HTML in your build pipeline

Related Resources

Related Glossary

Related Lessons

  • HTML

    Learn about HTML attributes.

← Back to language