The contenteditable Attribute — HTML Technical Interview Questions & Answers
Making any element directly editable by the user.
The contenteditable Attribute
- Making any element directly editable by the user.
- The contenteditable Attribute is an HTML attribute — extra info on the opening tag. Example: class, id, href, src, alt, for, type. <p class="fail">Fail</p>
- id is unique on the page. class can repeat. Don’t use the same id twice. Prefer class for CSS.
- Trap: styling with id for everything. Trap: inline style when a class would do.
Technical Interview Tip: The contenteditable Attribute: show it on a tag. id vs class if relevant.
Code Examples for The contenteditable Attribute
The contenteditable Attribute — working example
<section id="faq" class="panel panel--wide" data-topic="html">
<h2>FAQ</h2>
<p hidden>Screened until revealed</p>
<p contenteditable="true">Editable note</p>
</section>The contenteditable Attribute — id is unique; class is reusable; data-* stores custom values for CSS/JS hooks.
How to Explain The contenteditable Attribute to an Interviewer
What is The contenteditable Attribute?
An HTML attribute Goes on the opening tag