HTML is an interview-relevant foundation for web development and frameworks such as React. Strong answers connect markup fundamentals with browser behavior, accessibility, performance, and maintainable implementation. section 2.0
Interviewers commonly probe whether a candidate can:
- Explain how HTML and CSS support web interfaces while JavaScript and TypeScript provide programming capabilities around them. section 2.0
- Use HTML APIs beyond framework abstractions, including device access, clipboard operations, drag-and-drop, file access, storage, multimedia, messaging, and real-time communication. section 2.3
- Consult official documentation rather than memorizing every API, then account for permissions, compatibility, errors, accessibility, user experience, and resource management. section 2.3
Interview scenario: implement drag and drop
A practical solution stores an element identifier with dataTransfer during drag start, prevents the default drag-over behavior, retrieves the identifier on drop, and appends the matching element to the drop zone. The example uses React event handlers while exercising a browser HTML API directly. section 2.3
Listing 2.7 The drag-and-drop example
const DragAndDrop: React.FC = () => {
const handleDragStart = (e: React.DragEvent<HTMLDivElement>) => {
e.dataTransfer.setData('savedId', e.currentTarget.id); #A
};
const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault(); #B
};
const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {
const data = e.dataTransfer.getData('savedId'); #C
const draggableElement = document.getElementById(data);
const dropzone = e.target as HTMLElement;
dropzone.appendChild(draggableElement!); #D
};
return (
<div>
<h1>Drag and Drop API Demo</h1>
<div id="draggable" draggable="true" onDragStart={handleDragStart}> #E
I am draggable.
</div>
<div #F
id="dropzone"
onDragOver={handleDragOver}
onDrop={handleDrop}
>
Drop Zone
</div>
</div>
);
};
Inspect the complete drag-and-drop implementation, including draggable markup, event handlers, dataTransfer usage, and drop-zone behavior. section 2.3















