Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

HTML_interview

This document provides a series of HTML interview questions and answers, covering fundamental concepts such as the definition of HTML, types of lists, attributes, semantic elements, and differences between HTML versions. It also explains the purpose of various HTML tags and features like the alt attribute, DOCTYPE declaration, and web storage APIs. The content serves as a guide for individuals preparing for web development interviews.

Uploaded by

weirdvirel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

HTML_interview

This document provides a series of HTML interview questions and answers, covering fundamental concepts such as the definition of HTML, types of lists, attributes, semantic elements, and differences between HTML versions. It also explains the purpose of various HTML tags and features like the alt attribute, DOCTYPE declaration, and web storage APIs. The content serves as a guide for individuals preparing for web development interviews.

Uploaded by

weirdvirel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Certificate in full-stack web developer

*HTML interview question by ASP Computer<coding>*

1. What is HTML?

Answer: HTML (HyperText Markup Language) is the standard markup language


used to create web pages. It structures web content by using a series of elements
represented by tags. HTML is the foundation for web pages and works in
conjunction with CSS and JavaScript.

2. What are the different types of lists in HTML?

Answer: HTML supports three types of lists:

Ordered List (<ol>): A list of items with a defined sequence, typically numbered.

Unordered List (<ul>): A list of items without a specific sequence, typically


bulleted.

Definition List (<dl>): A list of terms and their descriptions, often used for
glossaries or metadata.

3. What is the difference between id and class attributes in HTML?

Answer:

id: Used to uniquely identify an element. Each id must be unique within a page,
meaning no two elements can share the same id.

class: Used to classify multiple elements under the same category. Multiple
elements can share the same class, and an element can have multiple classes.

4. What is the difference between div and span?

Answer:

div: A block-level element used to group larger sections of HTML, such as


paragraphs, headings, and other block-level elements.
span: An inline-level element used to group small sections of text or inline
elements for styling purposes.

5. What are semantic HTML elements?

Answer:

Semantic HTML elements clearly describe their meaning to both the browser and
the developer. Examples include:

<header>: Defines the header section of a document.

<footer>: Defines the footer section of a document.

<article>: Represents an independent piece of content.

<section>: Groups related content. Semantic HTML improves accessibility and


SEO.

6. What is the difference between inline, block, and inline-block


elements?

Answer:

Inline elements: Do not start on a new line and only take up as much width as
needed (e.g., <span>, <a>).

Block elements: Always start on a new line and take up the full width available
(e.g., <div>, <p>).

Inline-block elements: Behave like inline elements but allow setting of height and
width (e.g., <img>).

7. What is the alt attribute in images?

Answer:

The alt attribute provides alternative text for an image if the image cannot be
displayed. It is essential for accessibility as screen readers read the alt text to
visually impaired users.

8. What is the DOCTYPE declaration in HTML?

Answer:
The <!DOCTYPE> declaration is used to define the document type and version of
HTML used in the document. In HTML5, it is written as:

<!DOCTYPE html>

9. What is the difference between HTML5 and previous versions of


HTML?

Answer:

HTML5 introduced new features such as:

New semantic elements (<article>, <section>, <footer>, <header>).

Support for multimedia elements (<audio>, <video>).

New form input types (email, date, number).

APIs like localStorage, WebSockets, and geolocation.

10. How can you embed a video in an HTML document?

Answer:

You can embed a video using the <video> tag. For example:

<video controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

The controls attribute adds playback controls like play, pause, and volume.

11. What is the purpose of the meta tag in HTML?

Answer:

The <meta> tag provides metadata about the HTML document, such as character
set, author, and page description. Metadata is not displayed on the page but is
used by browsers, search engines, and other web services.

Example:
<meta charset="UTF-8">
<meta name="description" content="A guide to HTML interview questions.">

12. What is the difference between GET and POST methods in forms?

Answer:

GET: Appends form data to the URL as query parameters. This method is less
secure and should not be used for sensitive data.

POST: Sends form data in the HTTP request body, making it more secure and
suitable for sensitive information.

13. What are data attributes in HTML?

Answer: Data attributes allow you to store custom data in HTML elements. They
are defined using the data- prefix.

Example:

<div data-product-id="12345">Product Name</div>

JavaScript can access the value using dataset:

var productId = document.querySelector('div').dataset.productId;

14. What is the purpose of the <iframe> tag in HTML?

Answer:

The <iframe> tag is used to embed another HTML page within the current page.
It is commonly used to embed YouTube videos, Google Maps, or other web
content. Example:

<iframe src="https://www.example.com" width="600" height="400"></iframe>

15. What are web storage APIs in HTML5?


Answer:

HTML5 provides two types of web storage:

localStorage: Stores data with no expiration time. Data persists even after the
browser is closed.

sessionStorage: Stores data for the duration of the page session (data is lost
when the page is closed).

You might also like