Careeroza
Advanced Interview Questions
How does a browser render an HTML page?
- Parses HTML into the DOM tree and CSS into the CSSOM.
- Combines them into the render tree (visible elements only).
- Layout: computes the size and position of every box.
- Paint and composite: draws pixels in layers to the screen.
- Blocking scripts and CSS delay this, which is why scripts use
defer.
What is ARIA and when should you use it?
ARIA attributes (role, aria-label, aria-expanded, aria-live...) describe custom widgets to assistive technology. Use them only when native HTML cannot express the meaning: a real <button> beats <div role="button">.
How do you make a page accessible?
- semantic HTML and a logical heading order
langattribute and a descriptive title- alt text and labelled form fields
- keyboard support with visible focus
- sufficient color contrast
- testing with a screen reader and tools like Lighthouse/axe
What are data-* attributes?
Custom attributes for storing extra data on elements, read in JavaScript via element.dataset and in CSS via attribute selectors:
<button data-product-id="42" data-price="499">Add</button>
<script>
const btn = document.querySelector('button');
console.log(btn.dataset.productId, btn.dataset.price); // "42" "499"
</script>How can HTML improve page performance?
defer/asyncscriptsloading="lazy"on below-the-fold images and iframes- width/height on media to avoid layout shift
srcset/<picture>with modern formatspreconnect/preloadfor critical resources
What is the difference between the DOM and HTML source?
The HTML source is the text the server sent. The DOM is the live tree of objects the browser built from it, which JavaScript can change. DevTools "Elements" shows the DOM, so it can differ from "View Source".