Basics of HTML
What is HTML?
- HTML stands for HyperText Markup Language. It is the standard markup language used to create web pages.
What are the basic tags in HTML?
- Basic tags include
<html>,<head>,<title>,<body>,<h1>to<h6>,<p>,<a>,<img>,<ul>,<ol>,<li>,<div>,<span>, etc.
- Basic tags include
What is the structure of an HTML document?
- An HTML document typically consists of an
<!DOCTYPE>declaration,<html>,<head>, and<body>sections.
- An HTML document typically consists of an
What is semantic HTML?
- Semantic HTML refers to using HTML tags that convey the meaning of their content, rather than just presentation. Examples include
<header>,<nav>,<section>,<article>,<footer>,<aside>, etc.
- Semantic HTML refers to using HTML tags that convey the meaning of their content, rather than just presentation. Examples include
What is the purpose of the
<!DOCTYPE>declaration?- The
<!DOCTYPE>declaration specifies the document type and version of HTML being used in the document to ensure proper rendering by browsers.
- The
HTML Tags and Attributes
Explain the difference between
<div>and<span>tags.<div>is a block-level container used to group elements, while<span>is an inline container typically used for styling or grouping inline elements.
What are self-closing tags? Give an example.
- Self-closing tags are tags that don't have a closing tag and end with a slash (
/>). Example:<img src="image.jpg" alt="Image" />.
- Self-closing tags are tags that don't have a closing tag and end with a slash (
Explain the purpose of the
altattribute in<img>tags.- The
altattribute provides alternative text for an image if the image cannot be displayed. It also assists accessibility by providing descriptions of images to screen readers.
- The
How do you create a hyperlink in HTML?
- Use the
<a>tag with thehrefattribute. Example:<a href="https://example.com">Link Text</a>.
- Use the
What is the difference between the
titleattribute and thealtattribute?- The
titleattribute provides additional information about an element (e.g., tooltip text), whereas thealtattribute provides alternative text for images specifically.
- The
New Features and Best Practices
What are some new features introduced in HTML5?
- HTML5 introduced new elements like
<header>,<nav>,<section>,<article>,<footer>,<figure>,<figcaption>, new form input types (<input type="email">,<input type="date">, etc.),<canvas>,<audio>,<video>, and more.
- HTML5 introduced new elements like
Explain the importance of using semantic HTML5 elements.
- Semantic HTML5 elements improve accessibility, search engine optimization (SEO), and make the structure of web pages more meaningful and understandable.
What are some best practices for writing efficient HTML?
- Use semantic HTML5 elements, maintain a consistent indentation and coding style, use external CSS and JavaScript files, minimize inline styles and scripts, and ensure compatibility with different browsers.
Advanced HTML Concepts
What are data attributes in HTML?
- Data attributes (
data-*) allow you to store extra information on standard HTML elements for scripting purposes or other uses.
- Data attributes (
Explain the difference between HTML4, XHTML, and HTML5.
- HTML4 was the previous version with fewer features. XHTML is a stricter, XML-based version of HTML. HTML5 is the latest version with new features, better support for multimedia, and improved semantics.
How can you embed a video in HTML?
- Use the
<video>tag with appropriate attributes likesrc,controls, andautoplay(optional). Example:<video src="video.mp4" controls autoplay></video>.
- Use the
What are meta tags in HTML? Give examples of their usage.
- Meta tags provide metadata about an HTML document. Examples include
<meta charset="UTF-8">for specifying character encoding,<meta name="description" content="Description of the page">for SEO purposes,<meta http-equiv="refresh" content="30">for automatic refresh, etc.
- Meta tags provide metadata about an HTML document. Examples include
Coding and Debugging
How do you comment in HTML?
- Use
<!-- Comment -->for single-line comments or<!--and-->for multi-line comments.
- Use
What are some common issues you might face with cross-browser compatibility in HTML?
- Differences in rendering engines, CSS handling, JavaScript compatibility, and support for HTML5 features can lead to cross-browser compatibility issues.
Explain the concept of responsive design in HTML.
- Responsive design ensures that web pages render well on a variety of devices and window or screen sizes by using flexible grids, layouts, images, and CSS media queries.
Accessibility and SEO
How can you improve accessibility in HTML?
- Use semantic HTML5 elements, provide alternative text for images (
altattribute), ensure proper heading structure (<h1>to<h6>), use ARIA roles and attributes where necessary, and ensure keyboard accessibility.
- Use semantic HTML5 elements, provide alternative text for images (
What are ARIA attributes in HTML?
- ARIA (Accessible Rich Internet Applications) attributes are used to improve the accessibility and usability of web content for users with disabilities. Examples include
role,aria-label,aria-labelledby,aria-describedby, etc.
- ARIA (Accessible Rich Internet Applications) attributes are used to improve the accessibility and usability of web content for users with disabilities. Examples include
Miscellaneous
What are the differences between
GETandPOSTmethods in HTML forms?GETmethod appends form data to the URL in the form of query parameters and has limitations on data size.POSTmethod sends form data in the request body and is suitable for sensitive or large amounts of data.
How can you embed audio in HTML?
- Use the
<audio>tag with attributes likesrc,controls, and optional attributes such asautoplayandloop. Example:<audio src="audio.mp3" controls autoplay></audio>.
- Use the
Explain the concept of web storage in HTML5.
- Web storage (localStorage and sessionStorage) allows web applications to store data locally within the user's browser. It provides more storage capacity compared to cookies and has a simpler API.

Comments
Post a Comment