jiHTML
jiHTML
1. Tags: HTML documents are made up of elements, which are wrapped in tags. Tags are enclosed in angle brackets, for
example:
2. <tagname>content</tagname>
3. Attributes: Tags can have attributes that provide additional information. These attributes are written inside the opening tag.
For example, the <img> tag can have a src attribute to define the source of an image:
4. <img src="image.jpg" alt="Description of the image">
5. Elements: An element is everything between an opening and closing tag. For example:
6. <h1>This is a heading</h1>
7. Nested Elements: HTML elements can be nested inside each other, creating a hierarchy and structure for the webpage.
8. <div>
9. <p>This is a paragraph inside a div.</p>
10. </div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample Webpage</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is a sample paragraph.</p>
<a href="https://www.example.com">Click Here</a>
</body>
</html>
<h1> to <h6>: Headings, with <h1> being the largest and <h6> the smallest.
<p>: Paragraphs of text.
<a>: Links (anchors), typically used to navigate to other pages.
<img>: Images.
<ul>: Unordered lists.
<ol>: Ordered lists.
<li>: List items.
<div>: A block-level container used for grouping content.
HTML is the foundation for any webpage, and it works together with other technologies like CSS (for styling) and JavaScript (for
interactivity) to create dynamic and visually appealing websites.
HTML Basics
HTML (HyperText Markup Language) is the core language used to structure content on the web. It tells the web browser how to display
text, images, links, and other elements. Here are the fundamental concepts and elements you'll need to know when getting started with
HTML.
1. Basic Structure of an HTML Document
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
HTML allows you to format text using various tags. Here are some common ones:
Headings: There are six levels of headings, <h1> being the largest and <h6> the smallest.
<h1>This is a main heading</h1>
<h2>This is a secondary heading</h2>
Paragraphs: Text inside <p> tags is treated as a paragraph.
<p>This is a paragraph of text.</p>
Bold and Italics:
<b>This text is bold</b>
<i>This text is italic</i>
Links: Use the <a> tag to create hyperlinks. The href attribute specifies the destination URL.
<a href="https://www.example.com">Click here to visit Example</a>
Images: The <img> tag is used to display images. The src attribute defines the source (file path or URL) and alt provides
an alternate text if the image is not loaded.
<img src="image.jpg" alt="Description of the image">
4. Lists
<div>: A block-level container used to group content. It’s useful for structuring your page layout.
<div>
<p>This is inside a div.</p>
</div>
<span>: An inline container used to style parts of the text or other elements.
<p><span style="color: red;">This text is red.</span></p>
6. Tables
Tables are created using the <table>, <tr>, <th>, and <td> tags:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
</table>
7. Forms
Forms are used to gather user input. A basic form consists of input elements like text fields, radio buttons, checkboxes, and a submit
button:
8. Comments
You can add comments to your HTML code, which are ignored by the browser. Comments are helpful for explaining your code.
<!-- This is a comment -->
9. Attributes
HTML tags can have attributes that provide additional information about an element. Some common attributes include:
Example:
In HTML, elements can be categorized as block-level or inline elements based on how they behave in the layout of a webpage. Inline
elements are those that don't break the flow of the document. They only take up as much width as necessary and allow other elements to
sit next to them on the same line.
1. Do not start on a new line: Inline elements flow with the content, meaning they are displayed in the same line as the other inline
elements or text.
2. Only take up as much width as required: They do not expand to fill the entire width of their parent container.
3. Can be nested inside block elements: Inline elements can be placed within block elements, but not vice versa (you can't place a
block element inside an inline element).
Here are some of the most common inline elements used in HTML:
Used to create hyperlinks. Inline by default, the link text will flow with other content on the same line.
A generic inline container used for styling or grouping small portions of text or other elements.
Used to define text that should be strongly emphasized. Typically, it appears bold by default.
Used to embed images. The image element is inline, allowing it to be placed within text or other inline elements.
Displays text in a monospace font, typically used for code snippets. It is inline, meaning it does not disrupt the text flow.
Represents bold text. Though it’s a presentational element, it is often used for bolding words without implying strong emphasis (use
<strong> for semantic meaning).
Represents italic text. Similar to <b>, it's a presentational element, but <em> should be used for emphasized text.
Makes text smaller than the surrounding text, often used for legal disclaimers or fine print.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inline Elements Example</title>
</head>
<body>
<h1>HTML Inline Elements</h1>
<p>Welcome to my webpage. Here's a <a href="https://www.example.com">link</a> to an example
site, and this is a <span style="color:red;">red text</span>.</p>
<p>Here is a <strong>bold</strong> word and an <em>italicized</em> word in a sentence. The
word <code>console.log()</code> is used in JavaScript.</p>
<p><img src="https://via.placeholder.com/150" alt="Placeholder image" width="150"> And here
is an image displayed inline with text.</p>
<p>The <abbr title="International Business Machines">IBM</abbr> corporation is a
multinational company.</p>
</body>
</html>
Key Takeaways:
Inline elements allow other elements to sit alongside them, making them perfect for embedding smaller components within
larger blocks of content.
They don't create line breaks, making them suitable for fine-tuning the layout and ensuring a fluid, continuous flow of content.
Inline elements can be used for styling text, adding links, displaying images, and more, without disrupting the surrounding
content.
Understanding inline elements is essential for crafting well-structured and styled HTML content.
The <head> element in an HTML document contains metadata and other information about the document that is not directly visible to
the user on the webpage. It typically includes things like the title of the webpage, links to external files (CSS, JavaScript), and other
meta-information such as character encoding and viewport settings.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Title</title>
<link rel="stylesheet" href="styles.css">
<script src="script.js"></script>
</head>
Here are some of the most common elements you’ll find inside the <head> section:
The title is shown in the browser’s title bar or tab. It is important for both SEO (search engine optimization) and user experience.
<meta charset="UTF-8">: Specifies the character encoding for the document. UTF-8 is the most common encoding and
supports a wide range of characters from different languages.
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">: Helps with responsiveness,
ensuring that the page scales correctly on mobile devices. The width=device-width part ensures the page width is equal to
the width of the device's screen, and initial-scale=1.0 sets the initial zoom level.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
3. <link>: Defines the relationship between the current document and an external resource, typically
used for linking external CSS stylesheets or favicon icons.
Inline JavaScript:
<script>
console.log("Hello, world!");
</script>
6. <base>: Specifies a base URL for all relative URLs in the document. It is rarely used but can be
helpful in some cases where you want to set a default base URL for links and resources.
<base href="https://www.example.com/">
7. <meta> for SEO: There are several types of meta tags that help improve SEO, such as descriptions
and keywords.
Meta description: Provides a short description of the page content, which may appear in search engine results.
<meta name="description" content="This is an example webpage to learn HTML basics.">
Meta keywords: A list of keywords relevant to the page content (not used as much today in SEO, but still found in some cases).
<meta name="keywords" content="HTML, CSS, Web Development, Tutorial">
8. <meta> for author information: Specifies the author of the document.
<meta name="author" content="John Doe">
Here’s how the <head> section might look in a typical HTML document:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Character encoding -->
<meta charset="UTF-8">
Key Takeaways:
The <head> element contains metadata, links to external files (CSS, JavaScript), and other resources that help configure the
document, but it doesn't affect the visible content directly.
The <title> tag is essential because it provides the page title displayed in the browser's tab.
Meta tags like charset, viewport, and description help with encoding, responsive design, and SEO.
The <link> tag is used for linking to external resources like stylesheets and favicons.
You can include inline styles and scripts within the <head>, though it’s usually better to link to external resources for easier
maintenance and better performance.
The <head> element plays a crucial role in setting up the webpage’s metadata and resources, even though its contents are not visible to
the user.
HTML Forms
HTML forms are used to collect user input on a webpage. Forms allow users to interact with websites by submitting data, such as their
name, email, or any other information. Forms can be used to gather data for things like surveys, login screens, and feedback forms.
<form>: The container element for all form controls (input fields, buttons, etc.).
action: The URL where the form data will be sent when the form is submitted.
method: Specifies the HTTP method to be used when submitting the form. Common methods are GET and POST.
Form Elements
Here are some common form elements used to gather different types of user input:
1. Text Fields:
Text input fields are used to collect a single line of text from the user.
<label for="name">Name:</label>
<input type="text" id="name" name="name">
2. Password Field:
This is similar to a text field, but the input is hidden (for sensitive data like passwords).
<label for="password">Password:</label>
<input type="password" id="password" name="password">
3. Email Field:
An input field specifically for entering email addresses. Browsers may validate the email format.
<label for="email">Email:</label>
<input type="email" id="email" name="email">
4. Radio Buttons:
Radio buttons allow the user to select only one option from a set of predefined options.
<label for="male">Male</label>
<input type="radio" id="male" name="gender" value="male">
<label for="female">Female</label>
<input type="radio" id="female" name="gender" value="female">
name: Groups radio buttons together, so only one can be selected at a time.
value: The value sent to the server when the radio button is selected.
5. Checkboxes:
The <select> element creates a dropdown menu for the user to choose from.
<label for="country">Country:</label>
<select id="country" name="country">
<option value="usa">United States</option>
<option value="canada">Canada</option>
<option value="uk">United Kingdom</option>
</select>
7. Textarea:
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" cols="50"></textarea>
8. Submit Button:
9. Reset Button:
Here’s an example of a simple form that collects a user’s name, email, gender, and message, and then submits the data to a server:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form</title>
</head>
<body>
<h2>Contact Us</h2>
<form action="/submit_form" method="POST">
</form>
</body>
</html>
Explanation:
Action: When the form is submitted, the data will be sent to the /submit_form URL.
Method: The POST method sends form data to the server in a way that is not visible in the URL (unlike GET).
Form Fields: Includes text input for name and email, radio buttons for gender, a checkbox for a newsletter subscription, a textarea
for a message, and a submit button.
Form Attributes
Example:
Semantic HTML
Semantic HTML refers to using HTML tags that convey meaning about the content they enclose. These tags clearly describe their
purpose in a way that makes it easier for both humans and machines (like search engines and screen readers) to understand the
structure and content of a webpage.
1. Improved Accessibility: Semantic tags make it easier for screen readers to interpret content, helping people with disabilities
navigate websites.
2. SEO (Search Engine Optimization): Search engines prefer well-structured content, so semantic HTML helps improve your website's
visibility in search results.
3. Maintainability: Clear, meaningful markup is easier to maintain and collaborate on.
4. Readability: It’s easier for developers to read and understand the code because semantic tags provide context about the content.
1. <header>
Defines the introductory content or navigation for a page or section. It can contain elements like logos, navigation menus, or a search
bar.
<header>
<h1>My Website</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</nav>
</header>
2. <nav>
Represents a navigation section that links to other parts of the website or to external sites. It typically contains a menu of links.
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
3. <main>
Defines the main content of the document. It should be used for the primary content that is directly related to the topic of the page,
excluding headers, footers, sidebars, etc.
<main>
<h2>Welcome to My Website</h2>
<p>This is the main content of the page.</p>
</main>
4. <article>
Defines independent content that can stand alone, such as a blog post, news article, or user comment. It should be self-contained and
could be distributed or syndicated.
<article>
<h2>How to Learn Web Development</h2>
<p>Web development is an exciting field...</p>
</article>
5. <section>
Represents a section of content that is thematically related, such as a chapter, a group of related content, or a set of related articles. It
typically has its own heading.
<section>
<h2>Our Services</h2>
<p>We offer web design, development, and SEO services.</p>
</section>
6. <aside>
Represents content that is tangentially related to the main content, such as a sidebar, pull quotes, or advertisements. It can be placed
beside the main content.
<aside>
<h3>Related Articles</h3>
<ul>
<li><a href="#">How to Build a Portfolio</a></li>
<li><a href="#">Best Coding Practices</a></li>
</ul>
</aside>
7. <footer>
Defines the footer for a document or section, typically containing information like copyright, privacy policy, contact info, and links to
other pages.
<footer>
<p>© 2025 My Website. All rights reserved.</p>
<nav>
<a href="#">Privacy Policy</a> | <a href="#">Terms of Service</a>
</nav>
</footer>
8. <figure> and <figcaption>
Used together, these elements represent content like images, videos, diagrams, or illustrations with a caption.
<figure>
<img src="image.jpg" alt="A beautiful landscape">
<figcaption>Beautiful Landscape</figcaption>
</figure>
9. <details> and <summary>
Used to create interactive disclosures, where the user can click to reveal or hide more content. The <summary> tag is used to specify the
heading that will be visible initially.
<details>
<summary>More Information</summary>
<p>This is additional content that can be shown or hidden.</p>
</details>
10. <mark>
Used to highlight or mark text that is of special interest, such as search results or important sections of a document.
<p>Don't forget to read the <mark>important note</mark> at the end of the document.</p>
11. <time>
Represents a specific period in time (like a date or time). It's useful for marking events or timestamps.
Represents contact information for the author or owner of a document or section. It can include email, phone numbers, or physical
addresses.
<address>
<p>Contact us at <a href="mailto:[email protected]">[email protected]</a></p>
</address>
1. Improved Accessibility: Semantic elements help screen readers interpret content better, making the web more accessible to
visually impaired users.
2. Better SEO: Search engines can more easily understand the content and structure of a webpage, which can improve the page's
ranking in search results.
3. Clearer Code: It helps developers and others who maintain the code understand the structure and meaning behind each part
of the document.
4. Enhanced Maintainability: Using clear and meaningful tags makes your code easier to maintain and update as your project
grows.
5. Cross-device Consistency: Semantic HTML helps ensure that your content is presented consistently across different devices,
improving the user experience.
Here’s an example that demonstrates the use of semantic HTML to structure a basic webpage:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Blog</title>
</head>
<body>
<header>
<h1>My Personal Blog</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>Latest Posts</h2>
<article>
<h3>How to Learn HTML</h3>
<p>HTML is the foundation of web development...</p>
</article>
<article>
<h3>Understanding CSS</h3>
<p>CSS is used to style HTML content...</p>
</article>
</section>
<aside>
<h3>About Me</h3>
<p>I'm a web developer who loves learning new technologies.</p>
</aside>
</main>
<footer>
<p>© 2025 My Blog</p>
<nav>
<a href="#privacy-policy">Privacy Policy</a> | <a href="#terms-of-service">Terms of
Service</a>
</nav>
</footer>
</body>
</html>
Key Takeaways
Semantic HTML helps structure content in a way that is meaningful and accessible.
Using semantic tags like <article>, <section>, <header>, and <footer> improves SEO, accessibility, and
maintainability.
It’s essential to choose the appropriate tags for different types of content, allowing both users and machines to understand your
webpage better.
By using semantic HTML, you improve both the experience for users and the performance of your website on search engines.
When building websites or web applications, HTML, CSS, and JavaScript work together to create the structure, design, and interactivity
of a webpage. Here’s a brief overview of each:
HTML is the foundational markup language used to create the structure of web pages. It defines the content and organizes it into
elements like headings, paragraphs, images, links, forms, and more.
Key Points:
Structure: HTML provides the building blocks for web pages, like headers, paragraphs, images, and lists.
Elements: HTML uses tags (e.g., <h1>, <p>, <a>, <div>) to define various content types and layouts.
Attributes: HTML elements can have attributes (e.g., href, src, alt) that provide additional information about the element.
Example of HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Web Page</title>
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
</header>
<section>
<h2>About Me</h2>
<p>This is some text about me.</p>
</section>
<footer>
<p>© 2025 My Web Page</p>
</footer>
</body>
</html>
In this example:
HTML defines the structure with elements like <header>, <section>, and <footer>.
The text content is organized using heading tags (<h1>, <h2>) and paragraph tags (<p>).
CSS is used to style and format the layout of the HTML elements on the page. It controls the look and feel of the website, including
colors, fonts, spacing, positioning, and responsiveness.
Key Points:
Selectors: CSS applies styles to HTML elements using selectors (e.g., h1, .class, #id).
Properties: CSS defines how elements should be displayed using properties like color, font-size, margin, padding, and
display.
Layouts: CSS enables complex layouts through techniques like Flexbox, Grid, and traditional positioning.
Example of CSS:
/* Apply a background color to the body */
body {
background-color: #f4f4f4;
font-family: Arial, sans-serif;
}
In this example:
CSS styles the <body>, <header>, <section>, and <footer> elements to control their appearance.
The background color, text color, font styles, and padding are set to create a visually appealing page.
JavaScript adds interactivity and dynamic behavior to a webpage. While HTML structures the content and CSS designs it, JavaScript
makes it come alive with actions like animations, form validation, data fetching, and event handling.
Key Points:
Event Handling: JavaScript can respond to user actions like clicks, key presses, or form submissions.
Manipulating the DOM: JavaScript interacts with the HTML elements on the page (Document Object Model - DOM) to modify the
page dynamically (e.g., showing/hiding elements, changing content).
Functions and Logic: JavaScript enables you to write functions, loops, and conditionals to control how the website behaves.
Example of JavaScript:
// Display an alert when the button is clicked
document.getElementById("myButton").addEventListener("click", function() {
alert("Button clicked!");
});
In this example:
JavaScript listens for a button click and shows an alert when the button is pressed.
A function changeText() changes the inner text of an HTML element with the id myText.
Here’s an example where HTML, CSS, and JavaScript work together to create a functional webpage:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive Web Page</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
#message {
font-size: 20px;
margin-top: 20px;
color: #333;
}
</style>
</head>
<body>
<script>
document.getElementById("myButton").addEventListener("click", function() {
document.getElementById("message").innerHTML = "You clicked the button!";
});
</script>
</body>
</html>
Explanation:
HTML defines the structure, with a button (<button>) and a paragraph (<p>).
CSS styles the page, including the button's appearance and hover effect.
JavaScript adds interactivity, changing the text of the paragraph when the button is clicked.
Key Takeaways:
HTML provides the structure for web pages (content, headings, links, images).
CSS controls the layout and style, making the page look visually appealing.
JavaScript adds interactivity, enabling dynamic behavior and responding to user actions.
Together, these three technologies form the foundation of modern web development. They work in tandem to create functional,
attractive, and interactive websites. If you’re just starting out, learning how these technologies interact with each other is the first step
toward becoming a web developer!
In web development, graphics and media elements play a crucial role in enhancing the visual appeal and interactivity of websites. They
help in conveying information, enhancing user experience, and making content more engaging. Graphics and media include images,
videos, audio files, and other interactive elements like animations.
1. Images
Images are one of the most common forms of media used to visually represent content on a webpage. They can be used for product
images, background images, icons, illustrations, and more.
The <img> tag is used to embed images in a webpage. It doesn’t have a closing tag, but it requires the src attribute to specify the image
file path.
Example:
<img src="sunset.jpg" alt="A breathtaking sunset over the ocean">
Optimizing Images for the Web:
File Format: Use appropriate file formats such as JPG (for photos), PNG (for images with transparency), and SVG (for vector
images).
Compression: Use image compression tools (e.g., TinyPNG, ImageOptim) to reduce file size for faster loading times.
2. Background Images
CSS allows you to set images as background for elements such as the body, divs, or sections of a page.
Example:
div {
background-image: url('pattern.png');
background-repeat: repeat; /* Repeats the background image */
}
3. Videos
Videos can be embedded into web pages to convey dynamic or immersive content, such as tutorials, advertisements, or entertainment
media.
HTML Video Tag: <video>
The <video> tag is used to embed video files in a webpage. It supports multiple formats like MP4, WebM, and Ogg.
Example:
<video width="600" controls autoplay loop>
<source src="nature.mp4" type="video/mp4">
<source src="nature.webm" type="video/webm">
Your browser does not support the video tag.
</video>
Video Hosting:
Self-hosting: Uploading videos directly to your server (not always recommended due to large file sizes).
External hosting: Using platforms like YouTube or Vimeo to host videos and embed them on your site.
4. Audio
You can use audio files in web development to add sound effects, background music, or podcasts.
The <audio> tag is used to embed audio files, and like the video tag, it can include controls for play/pause, volume, and more.
<audio controls>
<source src="audio.mp3" type="audio/mp3">
<source src="audio.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
Example:
<audio controls autoplay>
<source src="background-music.mp3" type="audio/mp3">
<source src="background-music.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
SVG is a vector-based graphics format that allows for high-quality, scalable images without losing clarity. It's often used for logos, icons,
and illustrations.
Example of SVG:
<svg width="100" height="100" viewBox="0 0 100 100">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="yellow" />
</svg>
Advantages:
Scalable: SVG images do not lose quality when resized, making them ideal for responsive designs.
Editable: SVG images can be manipulated with CSS and JavaScript.
6. Canvas (HTML5)
The <canvas> element provides a space where you can draw graphics using JavaScript. It's commonly used for games, animations, or
custom graphical content.
Example of Canvas:
<canvas id="myCanvas" width="400" height="400"></canvas>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
// Draw a rectangle
ctx.fillStyle = "#FF0000";
ctx.fillRect(50, 50, 150, 100);
</script>
Animated graphics, such as GIFs or CSS animations, can be used to add visual effects and make a page more engaging.
.box {
animation: move 2s infinite;
}
In addition to the core HTML elements used for structure (like <div>, <header>, <footer>, etc.), HTML also provides a range of
additional elements and features that offer advanced functionality, accessibility, and versatility. These miscellaneous elements can be
used to improve user experience, content interaction, and web performance.
Here are some of the important miscellaneous HTML elements and features:
1. HTML Entities
HTML entities are special characters or symbols that cannot be typed directly in the code. They are represented by specific codes, often
starting with & and ending with a semicolon (;).
Examples:
Example:
<p>2 < 5</p>
<p>© 2025 Your Website</p>
Forms are a core component of web development, enabling user interaction with the page (e.g., signing up, searching, or submitting
data). In addition to basic form controls like text inputs, buttons, and checkboxes, HTML also includes specialized form elements.
Example:
<form action="/submit" method="post">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday">
<label for="range">Choose a number:</label>
<input type="range" id="range" name="range" min="0" max="100" step="1">
3. HTML Comments
HTML comments allow you to add notes to your code, which are helpful for documentation and explaining complex parts of the code.
Comments are ignored by the browser and do not appear in the rendered webpage.
Syntax:
<!-- This is a comment -->
<p>This is visible content.</p>
<!-- Remember to update the contact page later -->
Important:
Comments should not contain sensitive information, as they are visible in the source code.
Meta tags provide metadata about the document (e.g., title, description, and keywords) that is used by browsers, search engines, and
social media platforms.
Example:
<head>
<meta charset="UTF-8">
<meta name="description" content="Welcome to my personal blog">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Blog</title>
</head>
5. HTML <iframe>
An <iframe> (inline frame) is used to embed another HTML document or webpage within the current document. It is often used to
embed videos, maps, or other external content like social media posts.
Example:
<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" width="560" height="315" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
Attributes:
6. HTML <progress>
The <progress> tag is used to represent the progress of a task, such as a file download or form submission. It can show the percentage
of completion visually.
Example:
<progress value="70" max="100">70%</progress>
Attributes:
7. HTML <meter>
The <meter> tag is used to represent a scalar measurement within a known range, such as disk usage or temperature.
Example:
<label for="diskUsage">Disk Usage:</label>
<meter id="diskUsage" value="0.6" min="0" max="1">60%</meter>
Attributes:
The <details> tag creates a disclosure widget from which the user can reveal additional content. The <summary> tag defines the
visible heading or summary for the widget.
Example:
<details>
<summary>Click to learn more</summary>
<p>This is the additional information revealed when clicked.</p>
</details>
<b>: Represents bold text, but it has no semantic meaning. It's often used purely for styling.
<strong>: Represents important text, which is typically bold by default. It has semantic meaning and indicates that the
enclosed text is of strong importance.
Example:
<p>This is a <b>bold</b> word.</p>
<p>This is a <strong>strong</strong> word.</p>
10. HTML <q> and <blockquote>
Example:
<p>John said, <q>HTML is the foundation of the web.</q></p>
<blockquote cite="https://example.com">
<p>"The only limit to our realization of tomorrow is our doubts of today." - Franklin D.
Roosevelt</p>
</blockquote>
The <kbd> element is used to represent user input from a keyboard. It is typically used to display text that should be typed by the user,
like in a command line or form field.
Example:
<p>To save the document, press <kbd>Ctrl</kbd> + <kbd>S</kbd>.</p>
Example:
<p>The command to list files is <code>ls -l</code>.</p>
<pre>
function greet() {
console.log("Hello, World!");
}
</pre>
<bdi>: The Bi-directional Isolation element ensures that text is displayed correctly in mixed text directions (e.g., when mixing
left-to-right and right-to-left languages).
<bdo>: The Bi-directional Override element overrides the default directionality of text.
Example:
<p><bdi><مرحبا بالعالم/bdi></p>
<p><bdo dir="rtl">This text is right-to-left</bdo></p>