Explore the fundamentals of HTML with our collection of essential beginner-level questions.
Deepen your HTML knowledge with our advanced questions that cover state management and cross-platform compatibility.
Master HTML with our expert-level questions that delve into performance optimization and the inner workings of the HTML bridge.
Answer: - HTML stands for HyperText Markup Language. - It is the standard language used to create and design web pages. - HTML provides the structure for web documents by using tags and elements.
Answer: - **HTML5** includes new elements and attributes not present in older versions. - New semantic elements like `<header>`, `<footer>`, `<article>`, and `<section>` improve document structure. - HTML5 also introduces new input types for forms, multimedia elements like `<video>` and `<audio>`, and the Canvas API for graphics.
Answer: - The `<!DOCTYPE>` declaration defines the document type and version of HTML being used. - It helps the browser render the page correctly by specifying the HTML version. - Example: ```html <!DOCTYPE html> ```
Answer: - Semantic HTML elements clearly describe their meaning in a human- and machine-readable way. - Examples include `<header>`, `<footer>`, `<article>`, and `<nav>`. - They improve accessibility, SEO, and maintainability of web pages by providing clear structure.
Answer: - **`<div>`**: A block-level element used for grouping and styling larger sections of content. - **`<span>`**: An inline element used for styling smaller portions of text or other inline elements. - `<div>` starts on a new line and takes up the full width available, while `<span>` does not.
Answer: - The `<meta>` tag provides metadata about the HTML document. - Common uses include specifying character encoding, author information, and viewport settings. - Example: ```html <meta charset="UTF-8"> <meta name="description" content="A brief description of the page"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> ```
Answer: - Forms are created using the `<form>` tag. - Common form elements include: - `<input>`: For text fields, checkboxes, radio buttons, etc. - `<textarea>`: For multi-line text input. - `<select>`: For drop-down lists. - `<button>`: For submitting the form. - Example: ```html <form action="/submit" method="post"> <input type="text" name="username"> <input type="submit" value="Submit"> </form> ```
Answer: - HTML attributes provide additional information about HTML elements. - They are placed within the opening tag of an element and follow a `name="value"` format. - Examples: - `<a href="https://example.com">Link</a>` (where `href` is an attribute of the `<a>` element) - `<img src="image.jpg" alt="Description"> (where `src` and `alt` are attributes of the `<img>` element)
Answer: - The `<iframe>` tag is used to embed another HTML document within the current page. - It creates an inline frame that can display content from another source. - Example: ```html <iframe src="https://example.com" width="600" height="400"></iframe> ```
Answer: - **CSS**: Use the `<link>` tag within the `<head>` section. - Example: ```html <link rel="stylesheet" href="styles.css"> ``` - **JavaScript**: Use the `<script>` tag, preferably at the end of the `<body>` section or within the `<head>` with a `defer` attribute. - Example: ```html <script src="script.js" defer></script> ```
Answer: - The `<title>` tag sets the title of the web page. - It appears in the browser's title bar or tab. - Example: ```html <title>My Web Page</title> ```
Answer: - Use the `<a>` tag with the `href` attribute to create a hyperlink. - Example: ```html <a href="https://example.com">Visit Example</a> ```
Answer: - **`<b>`**: Makes text bold but does not indicate any importance. - **`<strong>`**: Makes text bold and indicates that the text is of strong importance. - Example: ```html <b>Bold text</b> <strong>Important text</strong> ```
Answer: - **Ordered List**: Use the `<ol>` tag with `<li>` elements. - **Unordered List**: Use the `<ul>` tag with `<li>` elements. - **Definition List**: Use the `<dl>`, `<dt>`, and `<dd>` tags for term definitions. - Example: ```html <ul> <li>Item 1</li> <li>Item 2</li> </ul> <ol> <li>First</li> <li>Second</li> </ol> <dl> <dt>Term</dt> <dd>Definition</dd> </dl> ```
Answer: - Data attributes are custom attributes that store extra information on HTML elements. - They are prefixed with `data-` and can be accessed using JavaScript. - Example: ```html <div data-role="admin" data-id="123">Content</div> ``` - Accessing data attributes in JavaScript: ```javascript let role = document.querySelector('div').getAttribute('data-role'); ```