HTML Elements — HTML Technical Interview Questions & Answers
Opening/closing tags, content and nesting rules.
HTML Elements
- Opening/closing tags, content and nesting rules.
- An element is the tag + its content: <p>Hello</p> is one paragraph element. Attributes live in the opening tag: <a href='/marks'>Marks</a>. Nesting makes a tree the browser (DOM) uses.
- Block elements (p, div, h1) start on a new line. Inline (span, a, strong) sit in the sentence.
- Trap: overlapping tags <p><strong></p></strong>.
Technical Interview Tip: <p>Hello <strong>Asha</strong></p>
Code Examples for HTML Elements
HTML Elements — working example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>HTML basics</title>
</head>
<body>
<!-- Comment: structure first, then content -->
<h1 id="top" class="title">Hello HTML</h1>
<p>Elements wrap content; attributes like <code>id</code> and <code>class</code> add meaning.</p>
<img src="/images/team.jpg" alt="Team practicing interviews" width="320" />
</body>
</html>HTML Elements — hTML structures content with elements and attributes; start every page with doctype, html, head, and body.
How to Explain HTML Elements to an Interviewer
What is an HTML element?
Tag + content Attributes on the opening tag