HTML Notes
HTML Notes
The history of HTML (Hypertext Markup Language) is closely tied to the development and evolution
of the World Wide Web. Here is a brief overview of the key milestones and versions in the history of HTML:
1. Tim Berners-Lee's Proposal (1989): HTML's origins can be traced back to the late 1980s when
British computer scientist Tim Berners-Lee, working at CERN (the European Organization for Nuclear
Research), proposed a system for sharing information among scientists by using a "hypertext"
system. This proposal laid the foundation for the World Wide Web.
2. HTML 1.0 (1993): The first official specification for HTML, known as HTML 1.0, was published in
1993. It introduced the basic structure of HTML documents, including elements like headings,
paragraphs, links, and lists.
3. HTML 2.0 (1995): HTML 2.0 was published in 1995 and added new features such as forms and
tables. This version of HTML helped in the early development of the web.
4. HTML 3.2 (1997): HTML 3.2, released in 1997, brought improvements in terms of support for tables
and frames. It was widely adopted and used during the mid- to late-1990s.
5. HTML 4.01 (1999): HTML 4.01 was released in 1999 and further refined the standard with features
like cascading style sheets (CSS) support and improved form handling.
6. XHTML 1.0 (2000): Extensible Hyper Text Markup Language (XHTML) was introduced in 2000, which
aimed to combine the benefits of XML with HTML. XHTML was an attempt to make HTML more
consistent and better structured.
7. HTML5 (2014): HTML5 is a major revision of the HTML standard. It introduced a wide range of new
elements, attributes, and APIs. HTML5 also incorporated multimedia elements like <video> and
<audio, support for local storage, and the <canvas> element for graphics.
8. HTML5.1 (2016) and HTML5.2 (2017): These were incremental updates to HTML5, introducing new
elements and features.
9. HTML Living Standard (Ongoing): Unlike previous versions with specific release dates, the HTML
specification has moved to a "living standard" model, where it continually evolves. The latest
features and improvements are added gradually, and there may not be distinct versions in the
traditional sense.
10. Web Components and Modern Web Technologies: HTML is now part of a broader ecosystem that
includes CSS and JavaScript. Modern web development involves using web components,
frameworks, and libraries to create interactive and dynamic web applications.
HTML Document Structure
HTML Document Structure: An HTML document is structured with opening and closing HTML tags.
The basic structure includes an opening <html> tag, which encloses two main sections: the <head> and
<body>. The <head> section contains metadata, while the <body> section contains the visible content of
the web page.
HTML Attributes
HTML elements often include attributes that provide additional information about an element.
Attributes are placed within the opening tag and have a name and a value. For example, the href attribute
in an anchor tag specifies the URL to link to.
There are some HTML attributes that can be used with various HTML elements to provide additional
information, behaviour, or styling. These attributes are not specific to a single element and can be applied
to many different elements. Here are some of the commonly used attributes that can be used with various
HTML elements:
1. id Attribute:
• Used to give an element a unique identifier. This identifier can be used for styling with CSS or
targeting the element with JavaScript.
• Can be applied to most HTML elements.
2. class Attribute:
• Used to assign one or more classes to an element. Classes are a way to group elements for
styling with CSS or targeting with JavaScript.
• Can be applied to most HTML elements.
3. style Attribute:
• Allows you to add inline CSS styles to an element for individual styling. It's not typically
recommended for large-scale styling but can be useful for small adjustments.
• Can be applied to most HTML elements.
4. title Attribute:
• Provides additional information about an element, and the information is displayed as a
tooltip when a user hovers over the element.
• Can be applied to most HTML elements.
These are some attributes common attributes can be used for any elements in html.
Head and Body Sections:
The <head> section contains metadata for the page, such as the page title, character encoding, and
links to external resources like stylesheets and scripts. The <body> section contains the visible content that
users see.
Headings:
Headings are used to define the structure and hierarchy of content. There are six levels of headings,
from <h1> (most important) to <h6> (least important).
Paragraph Tag:
The <p> element is used to create paragraphs of text.
Anchor tag
The anchor tag (<a>) in HTML is used to create hyperlinks, allowing users to navigate to other web
pages, resources, or specific sections within the same page. The primary attribute associated with the
anchor tag is the href attribute, which defines the URL of the destination. However, there are several other
attributes and options that can be used to customize the behavior and appearance of links. Here's an
explanation of the anchor tag and its different attributes:
1. href (Hypertext Reference): The href attribute is the most important attribute for the anchor tag. It
specifies the URL or destination to which the link points. It can be an absolute URL, a relative URL, or an
email address:
• Absolute URL:
<a href="https://www.example.com">Visit Example</a>
• Relative URL (link to a local page or resource):
<a href="about.html">About Us</a>
• Email link:
<a href="mailto:[email protected]">Contact Us</a>
2. target: The target attribute defines where the linked content will open. Common values include:
• _blank: Opens the link in a new tab or window.
• _self (default): Opens the link in the same window or tab.
• _parent: Opens the link in the parent frame or window.
• _top: Opens the link in the full body of the window.
Example using the target attribute to open a link in a new tab:
3. download: The download attribute is used to indicate that the linked resource should be downloaded
rather than navigated to. When set, the browser will prompt the user to download the linked content.
4. title: The title attribute provides additional information about the link. When a user hovers their cursor
over the link, the text in the title attribute is displayed as a tooltip.
5. aria-label (Accessibility Label): The aria-label attribute is used to provide an accessible label for screen
readers. It describes the purpose of the link, making it more accessible to users with disabilities.
6. Other Attributes: While these are the most commonly used attributes, the anchor tag can also accept
other attributes for various purposes, such as styling with CSS or JavaScript functionality.
These attributes can be combined and customized to create links that suit your specific needs. Links
are a fundamental part of web navigation and can greatly enhance the user experience on a website.
Images and Media
Images and Media are essential components of web content that can greatly enhance the visual and
auditory aspects of a web page. In this explanation, we'll cover how to add images, image attributes, and the audio
and video elements, along with their different attributes.
1. Navigate to the file for which you want to copy the path in File Explorer.
Here src attribute value was copied from the internet. The above path had been taken from the internet.
2. Audio Elements
1. <audio></audio>: This is the opening and closing tag that defines the audio element.
2. src: This attribute specifies the source URL of the audio file. You can use different audio formats (e.g.,
MP3, Ogg, WAV).
3. controls: Adds playback controls, allowing users to play, pause, adjust volume, and seek within the audio.
Multiple Sources:
To ensure compatibility with various browsers, you can provide multiple source files of different
formats using the <source> element.
The browser will choose the first supported format. Because all the browsers might not support
same video format. So, if possible, it’s better to add audio file with different file formats like the above.
• src="E:\K-391 ignite.mp3": This attribute specifies the source URL of the audio file. In this case, the
audio file is located at "E:\K-391 ignite.mp3" on your local file system.
• controls: This attribute adds audio playback controls, allowing users to play, pause, adjust volume,
and seek within the audio.
Other attributes in audio:
1. loop:
• Causes the audio to play in a continuous loop, restarting when it reaches the end.
2. muted:
• Mutes the audio when the page loads. Users can unmute it using the audio controls.
3. Video Elements
The <video> tag in HTML is used to embed video content directly into web pages. It provides a native way to
play video without the need for external plugins or video players. Here's a detailed explanation of the <video> tag
and its key attributes:
Basic Usage:
To embed a video in an HTML document, you use the <video> element. You specify the video file's source
with the src attribute and can provide playback controls for the user. Here's a basic example:
• <video>: This is the opening tag that defines the video element.
• src: This attribute specifies the source URL of the video file. You can use different video formats (e.g., MP4,
WebM).
• controls: This attribute adds video playback controls, allowing users to play, pause, adjust volume, and seek
within the video.
• src="E:\Movies\Gran.Turismo.2023.mkv": Specifies the source URL of the video file. In this case, the video
file is located on your local file system at "E:\Movies\Gran.Turismo.2023.mkv." Please note that using local
file paths like this will only work on your local machine.
• controls: This attribute adds video playback controls, allowing users to play, pause, adjust volume, and seek
within the video.
• autoplay: Automatically starts playing the video as soon as the page loads.
• muted: Mutes the video when the page loads. Users can unmute it using the video controls.
• loop: Causes the video to play in a continuous loop, restarting when it reaches the end.
Please be aware that using local file paths like "E:\Movies\Gran.Turismo.2023.mkv" in a web page will only work on
your local machine and won't be accessible to others on the internet. When publishing web content, it's typical to
use relative or absolute URLs to link to video files hosted on a web server.
Multiple Sources:
To ensure compatibility with various browsers, you can provide multiple source files of different formats
using the <source> element. The browser will choose the first supported format.
3. autoplay: Automatically starts playing the video as soon as the page loads.
7. aria-label: Provides an accessible label for the video, conveying its purpose or content to screen reader users.
HTML Comments:
HTML comments are used to include explanatory notes within the HTML code. These comments are
not visible in the web browser and do not affect the rendering of the webpage. They are primarily meant
for developers and are useful for providing documentation, explanations, or making temporary notes in the
code. HTML comments are enclosed within <!-- and --> tags.
<!-- This is an HTML comment -->
You can also use comments to explain your code or make notes for yourself and other developers working on
the same code. And anything that’s inside <!-- and --> will not be shown in the output window. We can see that
below.
Output:
HTML Lists
HTML Lists allow you to organize and structure content into various types of lists. There are three
main types of lists in HTML: Ordered Lists, Unordered Lists, and Definition Lists, each with its own set of
attributes and uses.
1. Ordered Lists (<ol>):
Ordered lists are used to create numbered lists. The <ol> and <li> elements are used to define an
ordered list. The common attributes used with ordered lists are:
• type: Specifies the type of numbering for list items. Possible values include:
• "1" (default): Arabic numerals (1, 2, 3...).
• "A": Uppercase letters (A, B, C...).
• "a": Lowercase letters (a, b, c...).
• "I": Uppercase Roman numerals (I, II, III...).
• "i": Lowercase Roman numerals (i, ii, iii...).
• start: Specifies the starting value for the list items. This allows you to set a custom number from
which the list should begin. The attributes value can only be number. Below is the example and
output.
Nested List
A nested list nothing but a list inside a list. That can be any type ordered, unordered or Definition
list.
Tables in HTML.
Tags used in HTML Tables
1. <table> Element:
• The <table> element is the container for the entire table. It encloses all the other table
elements.
2. <caption> Element:
• The <caption> element provides a title or caption for the table. In this example, the caption
is "Monthly Expenses."
3. <thead> Element:
• The <thead> element defines the table header section. This section typically contains row(s)
that define the column headers. It helps in associating labels with the data in the table.
4. <tr> Element (Table Row):
• Inside the <thead>, you have a single <tr> element representing a table row for the column
headers.
5. <th> Element (Table Header Cell):
• Inside the header row, you have two <th> elements, which are used to define header cells.
These cells contain labels for the two columns: "Category" and "Amount."
6. <tbody> Element:
• The <tbody> element defines the table body section, where the actual data rows are placed.
7. <tr> Elements (Table Data Rows):
• Inside the <tbody>, there are two <tr> elements, each representing a data row. These rows
contain the actual data.
8. <td> Elements (Table Data Cells):
• Inside each data row, there are two <td> elements, which represent data cells. The first <td>
contains the category name ("Rent" and "Utilities"), and the second <td> contains the
corresponding amounts ("$1000" and "$200").
9. <tfoot> Element:
• The <tfoot> element defines the table footer section, often used for summaries or additional
information at the bottom of the table. It is structured similarly to the <thead> and can
contain rows and cells as needed.
HTML table Attributes:
1. border: This attribute specifies the width of the table border. For example, <table border="1"> will
create a table with a border of 1 pixel.
2. cellpadding: This attribute specifies the padding within individual table cells. It controls the space
between the content of a cell and the cell's border.
3. cellspacing: This attribute specifies the spacing between table cells. It controls the space between
adjacent cells.
4. width: This attribute specifies the width of the table. You can set it to a specific pixel value or a
percentage of the available space.
5. height: This attribute specifies the height of the table. Similarly, you can set it to a specific pixel
value or a percentage.
6. summary: The summary attribute is used to provide a summary or description of the table's
content, which can be beneficial for accessibility purposes.
7. caption: The <caption> element is used to add a title or caption to the table. It's typically placed
inside the <table> element.
8. colspan and rowspan: These attributes are used in table cells to merge cells horizontally (colspan)
or vertically (rowspan). For example, if you want to merge two cells across columns, you can use
colspan="2".
9. scope: The scope attribute is used with <th> elements to specify whether a header cell pertains to a
row ("row") or a column ("col"). This can improve accessibility for screen readers.
Look at the example code in the next page and the output in the following page.
The Same page when CSS applied.
Marquee Tag
The <marquee> tag is used to create scrolling or moving text or images on a web page. It's a simple way to
add animation or motion to your content, but it's not commonly used in modern web development. Still,
understanding how it works can be informative.
Here are the key attributes of the <marquee> tag:
1. direction: It specifies the direction of the scrolling, such as "left," "right," "up," or "down."
2. scrollamount: This attribute controls the speed of scrolling. A higher value makes the content move
faster.
3. scrolldelay: It sets the delay (in milliseconds) before the scrolling starts.
4. loop: You can specify how many times the scrolling should repeat. A value of "-1" indicates an
infinite loop.
Here's a basic example of how to use the <marquee> tag to create scrolling text:
While the <marquee> tag was popular in the early days of the web for creating animations and scrolling
text, it has several drawbacks and is no longer recommended:
1. Accessibility: <marquee> is not accessible, as it can be disorienting and difficult for users with
disabilities to interact with.
2. Usability: Scrolling text can be distracting and irritating to many users, leading to a poor user
experience.
3. Cross-browser Compatibility: <marquee> is not well-supported in modern browsers, and its
behaviour can vary between different browsers.
4. Deprecated: It is considered obsolete and has been removed in HTML5, though some browsers may
still support it for backward compatibility.
To achieve scrolling or animation effects in modern web development, it is recommended to use CSS
animations and transitions for smoother, more controllable, and accessible effects. JavaScript can also be
used to create dynamic and interactive animations on web pages.
iframe tag in html
An <iframe> (short for "inline frame") is an HTML element used to embed another HTML document
or web page within the current web page. It allows you to display content from another source, such as a
different website, a video, a map, or any web page, within a designated section of your page. Iframes are a
powerful tool for integrating external content into your website. Here's a detailed explanation of how
iframes work and how to use them:
Basic <iframe> structure:
2.Choose a location
3.Embedding pdf.
Inside src attribute paste the path of pdf file and define height and width. Refresh the page.
• Security: Be cautious about embedding content from untrusted sources, as it may pose security
risks. It's essential to ensure that the content you embed does not contain malicious code.
• Responsiveness: When using iframes, consider how they will behave on different screen sizes. You
may need to make your iframes responsive by adjusting the width and height using CSS or by using
CSS frameworks like Bootstrap.
• Accessibility: Ensure that the content within the iframe is accessible and does not create issues for
users with disabilities.
• Loading time: Be aware that loading content from external sources may impact the loading time of
your web page, especially if the external content is slow to load.
In summary, iframes are a versatile tool for embedding content from external sources into your web pages.
However, they should be used with caution and attention to security and user experience considerations.
HTML Entities:
HTML entities are special codes used in HTML documents to display characters that have special
meanings in HTML or that are not easily typed on a keyboard. They are typically used to display reserved
characters, such as < and >, or characters with special meanings in HTML, like & (ampersand), or to display
characters from character sets or languages that are not easily entered via a keyboard.
HTML entities are represented by their entity names or entity numbers, enclosed in an ampersand (&) and
a semicolon (;). The basic syntax is:
1. Using Entity Names:
• &entity_name; (e.g., < for <, > for >)
2. Using Entity Numbers(Decimal codes):
• &#entity_number; (e.g., < for <, > for >)
Here are some common HTML entities:
• < or <: Less than symbol (<)
• > or >: Greater than symbol (>)
• & or &: Ampersand (&)
• " or ": Double quotation mark (")
• ' or ': Single quotation mark (')
• © or ©: Copyright symbol (©)
• ® or ®: Registered trademark symbol (®) Scan above QR to get HTML
Decimal code for Entities
• € or €: Euro currency symbol (€)
• £ or £: Pound sterling currency symbol (£)
Below is the example and sample output
HTML Text formatting tags
1. <b> and <strong> Tags:
• <b> is used for making text bold.
• <strong> is used to indicate that the enclosed text is of strong importance.
2. <i> and <em> Tags:
• <i> is used for italicizing text.
• <em> is used to emphasize the enclosed text.
3. <u> Tag:
• <u> is used for underlining text.
4. <s> and <del> Tags:
• <s> is used for striking through text.
• <del> is used to indicate deleted or removed text.
5. <sup> and <sub> Tags:
• <sup> is used for superscript text (raised above the line).
• <sub> is used for subscript text (lowered below the line).
6. <span> Tag:
• <span> is a generic inline container that is often used with CSS for applying styles to a
specific part of text.
7. <font> Tag (deprecated):
• The <font> tag was used to set font-related attributes like size and color. However, it's
deprecated in HTML5, and it's better to use CSS for font styling.
8. <mark> Tag:
• <mark> is used to highlight and mark a section of text.
9. <code> Tag:
• <code> is used to display inline code or code snippets.
10. <pre> Tag:
• <pre> is used to display preformatted text. It preserves spacing and line breaks.