Interview Question

What is the datalist tag?

`<datalist>` should be used for its proper HTML purpose.

💡 Concept ✅ Quick Revision 🌐 HTML

Answer

`<datalist>` is an element that provides suggested values for another control. • Connect it to an `<input>` by matching the input `list` attribute to the datalist `id`. • Browsers apply the native parsing and behavior defined for this element. • Using its native meaning helps assistive technology understand the content when the element has accessibility semantics.

💡 Simple Example

<label for="browser">Browser</label><input id="browser" name="browser" list="browser-options"><datalist id="browser-options"><option value="Firefox"><option value="Chrome"></datalist>

⚡ Quick Revision

`<datalist>` should be used for its proper HTML purpose.