HTML
What is HTML?
What are semantic tags in HTML 5?
- <div> is a block level element
- <span> in a inline element
use <div> for layout and <span> for styling part for text
What is difference between id and class in HTML
id : Unique identifier, used once per page
class : Can be reused on multiple page
What are tags and attributes in HTML?
tags : Tags in HTML are used to define elements on a web page. They tell the browser how to display the content. Most tags come in pairs: an opening tag and a closing tag.
<p>This is a paragraph.</p>
attributes : Attributes provide additional information about an HTML element. They are always included in the opening tag and usually come in name/value pairs like name="value"
<a href="https://google.com">Visit Google</a>
Here,
href
is an attribute that specifies the link destination.
What are Semantic HTML Elements?
Semantic : HTML elements clearly describe their meaning and role in the page layout.
Examples of Semantic Elements
- <header>
- <nav>
- <section>
- <article>
- <footer>
How do you create a hyperlink in HTML?
Use the <a>
tag with the href
attribute to create a hyperlink.
<a href="https://example.com">Visit Site</a>
How can you embed an image in HTML?
Use the <img>
tag with the src
attribute to embed an image.
<img src="image.jpg" alt="Description">
src
specifies the image file path
alt
provides alternative text if the image doesn't load
What is the role of the tag?
The <head>
tag contains metadata about the HTML document, such as the title, character set, CSS links, and scripts. It doesn’t display content on the page but helps the browser understand and load the page properly.
How do you create a table in HTML?
Use the <table>
tag along with <tr>
, <th>
, and <td>
to create a table.
How do you create a form in HTML?
Use the <form>
tag along with input elements like <input>
, <textarea>
, and <button>
.
action
= where to send the form datamethod
= how to send the data (get
orpost
)
What is the purpose of the attribute in tags?
The attribute in HTML tags provides additional information or functionality about an element. It’s used to modify the behavior, appearance, or other properties of HTML tags. Think of attributes like extra instructions that tell the browser how to handle or display an element.
What are block-level and inline elements? Give examples.
Take up the full width of the page and start on a new line.
<div>
, <p>
, <h1>
, <section>
, <table>
Take up only as much width as needed and do not break to a new line.
<span>
, <a>
, <strong>
, <img>
, <label>
How do you create an ordered and unordered list?
Use the <ol>
tag with <li>
items.
Use the <ul>
tag with <li>
items.
<ol>
= ordered list
HTML5 is more powerful, supports multimedia, better structure (semantic tags), and is mobile-friendly compared to HTML4.
How do you embed audio and video in HTML5?
Embed Audio:
Use the <audio>
tag with the controls
attribute.
Embed Video:
Use the <video>
tag with the controls
attribute.
✅ controls
= shows play, pause, volume buttons
✅ source
= defines the media file and its type
<title>
element?<form>
element?<meta>
element?
type="email"
– must be a valid emailmin
,max
,maxlength
– limits values or lengthpattern
– regex pattern matchrequired
– field must be filled
New Input Types in HTML5:
- url
- tel
- number
- range
- date
- color
How would you implement lazy loading of images in HTML5?
Use the loading="lazy"
attribute in the <img>
tag.
It delays loading the image until it’s about to enter the viewport (visible area), which improves page speed.
Benefits:
- Faster initial page load
- Saves bandwidth
- Improves performance, especially on long pages
This feature is supported in all modern browsers.
What is a viewport meta tag? Why is it important for responsive design?
The viewport meta tag is an essential element in web development for controlling how a webpage is displayed on various devices, especially mobile devices. It specifies the visible area of a webpage and enables the layout to adapt based on the device's screen size.
Viewport meta tag: Controls how a webpage is displayed on different devices (especially mobile).
How do you link external CSS and JS files in HTML?
Comments
Post a Comment