HTML
HTML
HTML is a language that is interpreted by the browser and it tells the browser what to display and how to display.
"Hypertext" refers to links that connect web pages to one another, either within a single website or between websites.
A markup language is used to define the text document within the tag which defines the structure of web pages.
HTML uses "markup" to annotate text, images, and other content for display in a Web browser. HTML markup includes special "elements"
such
as <head>, <title>, <body>, <header>, <footer>, <article>, <section>, <p>, <div>, <span>, <img>, <aside>, <audio>, <canvas>,
<datalist>, <details>, <embed>, <nav>, <search>, <output>, <progress>, <video>, <ul>, <ol>, <li> and many others.
To annotate text means to add notes, comments, or explanations to a text. This can include highlighting, underlining, or writing in the
margins to provide additional information, clarify meanings, or express personal reactions.
Annotations help in understanding and remembering the content better, making it a useful strategy for studying and analyzing texts.
What is HTML5?
HTML5 is the latest version of HyperText Markup Language, which supports multimedia, tags and elements, improved document markups
and new APIs
1. New Elements and Attributes: HTML5 introduces new semantic elements like <header>, <footer>, <article>,
and <section> to better define the structure of web pages12.
2. Multimedia Support: It includes native support for audio and video elements through the <audio> and <video> tags,
eliminating the need for external plugins12.f
3. Graphics and Effects: The <canvas> element allows for dynamic, scriptable rendering of 2D shapes and bitmap images, and it
also supports scalable vector graphics (SVG)12.
4. Form Enhancements: HTML5 provides new input types (e.g., email, date) and attributes for better form validation and user
experience12.
5. APIs and DOM: It includes various APIs like the Geolocation API, Web Storage API, and more, which enhance the functionality of
web applications1
Feature Html Html5
s
definition A hypertext markup language HTML5 is a new version of HTML with new functionalities with markup language with Internet technolo
(HTML) is the primary language for
developing web pages.
Multimedi Language in HTML does not have HTML5 supports both video and audio.
a support support for video and audio.
Storage The HTML browser uses cache HTML5 has the storage options like:application cache, SQL database, and web storage.
memory as temporary storage.
Browser HTML is compatible with almost all In HTML5, we have many new tags, elements, and some tags that have been removed/modified, so
compatibil browsers because it has been
ity present for a long time, and the
browser made modifications to
support all the features.
Graphics In HTML, vector graphics are In HTML5, vector graphics are supported by default.
support possible with tools LikeSilver
light, Adobe Flash, VML, etc.
Threading In HTML, the browser interface and The HTML5 has the JavaScript Web Worker API, which allows the browser interface to run in multiple t
JavaScript running in the same
thread.
Storage Uses cookies to store data. Uses local storage instead of cookies
Vector Vector graphics are possible with Vector graphics is an integral part of HTML5, SVG and canvas.
and the help of technologies like VML,
Graphics Silverlight, Flash,etc.
Shapes It is not possible to create shapes We can draw shapes like circles, rectangles, triangles.
like circles, rectangles,
triangles.
Doc type Doctype declaration in html is too The DOCTYPE declaration in html5 is very simple "<! DOCTYPE html>
long
<! DOCTYPE HTML PUBLIC "- //
W3C // DTD HTML 4.01 // EN"
"[Link]
dtd">
Character Character encoding in HTML is too Character encoding declaration is simple <meta charset = "UTF-8">
Encoding long.
<! DOCTYPE HTML PUBLIC "- //
W3C // DTD HTML 4.0
Transitional // EN">
Multimedi Audio and video are not the part of Audio and video are essential parts of HTML5,like: <Audio>, <Video>.
a support HTML4.
Vector In HTML4, vector graphics are Vector graphics are an integral part of HTML5, SVG, and canvas.
Graphics possible with the help of
techniques like VML, Silver light
and Flash.
Shapes It is not possible to draw shapes Using html5, you can draw shapes like circles, rectangles, triangles.
like circles, rectangles, triangles.
Browser Works with all older browsers A new browser supports this.
Support
HTML tags are the building blocks of HTML (HyperText Markup Language) used to create and structure web pages. They are enclosed in
angle brackets (< >) and typically come in pairs: an opening tag and a closing tag. The closing tag has a forward slash (/) before the tag
name.
HTML tags are keywords that instruct web browsers on how to display and format a web page.
Anatomy of an HTML element
Attributes
Attributes contain extra information about the element that you don't want to appear in the actual content.
The class attribute allows you to give the element a non-unique identifier that can be used to target it (and any other elements with the
same class value) with style information and other things.
You can put elements inside other elements too — this is called nesting.
Some elements have no content and do not have closing tags are called void elements. Take the <img>
The <!DOCTYPE> declaration in an HTML document serves a crucial role. It informs the web browser about the version of HTML being used,
ensuring that the browser renders the page correctly. Here are some key points about <!DOCTYPE>
Including a <!DOCTYPE> declaration triggers standards mode, where the browser renders the page according to modern web
standards. Without it, the browser may enter quirks mode, leading to inconsistent rendering across different browsers.
Document Type Definition (DTD): In older versions of HTML (like HTML 4.01), the <!DOCTYPE> declaration was more complex and
included a reference to a Document Type Definition (DTD), which specified the rules for the HTML document structure
The <html> tag is fundamental in an HTML document as it represents the root of the document.
1. Root Element: The <html> tag encapsulates all other HTML elements (except for the <!DOCTYPE> declaration). It signifies
the beginning and end of an HTML document 12.
2. Language Declaration: It often includes the lang attribute to specify the language of the document, which helps
search engines and browsers understand the content better 1.
3. Structure: Inside the <html> tag, you typically have two main sections:
o <head>: Contains meta-information about the document, such as the title, character set, and links to stylesheets.
o <body>: Contains the actual content of the document, such as text, images, links, and other elements.
<meta charset="utf-8">
Character Encoding: It tells the browser to use UTF-8 encoding, which supports a wide range of characters from different languages,
including special symbols and emojis.
<meta name="viewport" content="width=device-width"> tag is essential for creating responsive web designs. Here’s why it’s important:
1. Responsive Design: It ensures that your web page adjusts its layout based on the device’s screen size. This is crucial for making your website
look good on both desktop and mobile devices.
2. Viewport Width: The width=device-width part sets the width of the page to match the width of the device’s screen. This means the content will
fit the screen size of the device, whether it’s a phone, tablet, or desktop.
3. Initial Scale: Often, you’ll see this tag used with initial-scale=1.0, which sets the initial zoom level when the page is first loaded by the browser.
<title></title> — the <title> element. This sets the title of your page, which is the title that appears in the browser tab the page is loaded in. It is
also used to describe the page when you bookmark/favorite it.
The <title> contents are also used in search results.
name specifies the type of meta element it is; what type of information it contains.
Two such meta elements that are useful to include on your page define the author of the page, and provide a concise description of the page.
the keyword <meta> element (<meta name="keywords" content="fill, in, your, keywords, here">) — which is supposed to provide
keywords for search engines to determine the relevance of that page for different search terms — is ignored by search engines, because
spammers were just filling the keyword list with hundreds of keywords, biasing results.
<h1> represents the main heading, <h2> represents subheadings, <h3> represents sub-subheadings, and so on.
Semantic elements in HTML are elements that clearly describe their meaning in a human- and machine-readable way. These elements not
only define the structure of the content but also give it clear context and meaning, making it easier for both developers and browsers to
understand the webpage's structure.
Examples of non-semantic elements: <div> and <span> - Tells nothing about its content.
Examples of semantic elements: <form>, <table>, and <article> - Clearly defines its content.
<article>
<aside>
<details>
<figcaption>
<figure>
<footer>
<header>
<main>
<mark>
<nav>
<section>
<summary>
<time>
1. Accessibility: Helps screen readers understand the content better, making websites more accessible for
people with disabilities.
2. SEO: Improves search engine rankings by helping search engines understand the content.
3. Readability: Makes the code easier to read and maintain for developers.
4. Consistency: Creates a consistent structure across web pages, enhancing user experience.
5. Future-Proofing: Ensures compatibility with future web technologies and browsers.
HTML <article> Element
The <article> element specifies independent, self-contained content.
An article should make sense on its own, and it should be possible to distribute it independently from the rest of the
web site.
Forum posts
Blog posts
User comments
Product cards
Newspaper articles
The <article> element in HTML is used to represent a self-contained piece of content that can be independently
distributed or reused. This could include things like blog posts, news articles, forum posts, or any other independent
item of content.
The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
The <figcaption> tag defines a caption for a <figure> element. The <figcaption> element can be placed as the first or as
the last child of a <figure> element.
The <header> element represents a container for introductory content or a set of navigational links.
Footer
Footer located at the bottom of any article or document, they can contain contact details, copyright
information etc. There can be multiple footers on a page.
authorship information
copyright information
contact information
sitemap
back to top links
related documents
Main
It defines the main content of the document. The content inside the main tag should be unique.
According to W3C's HTML documentation: "A section is a thematic grouping of content, typically with a heading."
Chapters
Introduction
News items
Contact information
HEADING
In HTML, headings are used to define the titles or subtitles of sections on a webpage.
HTML headings, from <h1> to <h6>, indicate content hierarchy and importance. Search engines use them for indexing. Users navigate
by headings. Employ <h1> for main titles, <h2> for subsections, and progressively lower levels for less important content to maintain
structure and readability.
<h1>: Main heading, used for the most important title.
<h2>: Subheading, used for sections under the main heading.
<h3>: Sub-subheading, used for subsections under <h2>.
<h4>: Further subsections under <h3>.
<h5>: Even smaller subsections.
<h6>: The smallest heading, used for the least important titles.
The default size of HTML headings can be changed, using the style attribute.
PARAGRAPH
In HTML, a paragraph is defined using the <p> tag. Paragraphs are block-level elements, meaning they start on a new line and take up the
full width available.
Key Points:
New Line: Each paragraph starts on a new line.
Spacing: Browsers automatically add some space (margin) before and after each paragraph for better readability 12.
Block-Level Element: Paragraphs are block-level elements, meaning they occupy the full width of their container
LISTS
An HTML list is a record of related information used to display the data or any information on web pages in the ordered or unordered
form.
HTML Lists are used to specify lists of information. All lists may contain one or more list elements. There are three different types of HTML
lists:
1. Ordered List or Numbered List (ol)
2. Unordered List or Bulleted List (ul)
3. Description List or Definition List (dl)
Note: We can create a list inside another list, which will be termed as nested List.
<ul
> Defines an unordered list
<ol
> Defines an ordered list
<dl
> Defines a description list
Unordered
Unordered lists are used to mark up lists of items for which the order of the items doesn't matter. Let's take a shopping list as an
example:
milk
eggs
bread
hummus
The unordered list items are marked with bullets. It is also known as bulleted lists. An unordered list starts with the <ul> tag. Each list
item starts with the <li> tag.
Attribute: This tag contains two attributes which are listed below:
compact: It will render the list smaller.
type: It specifies which kind of marker is used in the list.
Ordered
Ordered lists are lists in which the order of the items does matter. Let's take a set of directions as an example:
In an ordered list, all list items are marked with numbers by default. An ordered list starts with the <ol> tag. Each list item starts with
the “li” tag.
Attributes:
compact: It defines the list should be compacted (compact attribute is not supported in HTML5. Use CSS instead.).
reversed: It defines that the order will be descending.
start: It defines from which number or alphabet the order will start.
type: It defines which type(1, A, a, I, and i) of the order you want in your list of numeric, alphabetic, or roman numbers.
The compact attribute in HTML was used to reduce the space between items in a list, making the list appear more compact.
Aries
-One of the 12 horoscope sign.
Bingo
-One of my evening snacks
HTML Nested List
A list within another list is termed as nested list. If you want a bullet list inside a numbered list then such type of list will called as nested
list.
LINE BREAK
In HTML, a line break is created using the <br> tag. This tag is an empty element, meaning it doesn’t have a closing tag. It’s used to insert
a single line break, similar to pressing “Enter” on your keyboard.
<b> (Bold):
Purpose: Used for stylistic purposes to make text bold without implying any extra importance or emphasis.
<strong> (Strong):
Purpose: Used to indicate that the text is of strong importance or emphasis. It conveys semantic meaning, which can be
understood by screen readers and search engines.
Key Differences:
Semantic Meaning: <strong> adds semantic meaning, indicating importance, while <b> is purely for visual styling12.
Accessibility: Screen readers and search engines recognize <strong> as important, but <b> is just bold text without additional
significance12.
what is difference between italic and emphasized?
<i> (Italic):
Purpose: Used for stylistic purposes to indicate text that is set off from the normal prose, such as foreign words, technical terms,
or fictional character thoughts.
<em> (Emphasis):
Purpose: Used to emphasize text, indicating that it should be read with more stress or importance. This tag adds semantic
meaning, which can be recognized by screen readers and search engines.
Key Differences:
Semantic Meaning: <em> adds semantic emphasis, indicating importance, while <i> is purely for visual styling12.
Accessibility: Screen readers and search engines recognize <em> as emphasized text, but <i> is just italicized text without
additional significance.
COMMENTS
In HTML, comments are used to add notes or explanations within the code that are not displayed in the browser. They help developers
understand the code better and can be useful for debugging or temporarily disabling code. Comments are enclosed within <!-- and -->
2. Multi-Line Comment:
o Used to comment out multiple lines of code.
<!--
This is a multi-line comment.
It spans multiple lines.
-->
BACKGROUND COLOR & TEXT COLOR
In HTML, you can set the background color & text color of an element using the background-color & color property in CSS. There are
several ways to do this:
1. Inline CSS:
Add the style attribute directly to the HTML element.
2. Internal CSS:
Use the <style> tag within the <head> section of your HTML document.
3. External CSS:
Link to an external CSS file using the <link> tag.
COLOR VALUES
HTML Colors can be applied to text, backgrounds, borders, links, forms, tables, etc.
Color Values
Color values in HTML define the color of elements. They can be specified using various formats such as hexadecimal, RGB, RGBA, HSL,
HSLA, color names, and system color keywords.
What is RGB?
RGB stands for Red, Green, and Blue. It’s an additive color model used primarily for sensing, representation, and display of images in
electronic systems, such as televisions and computers. The RGB model is based on the human perception of colors.
Each parameter (red, green, and blue) defines the intensity of the color with a value between 0 and 255.
This means that there are 256 x 256 x 256 = 16777216 possible colors!
Conclusion
Understanding the RGB color model is essential for anyone working with digital media, web design, or any field that
involves color representation on screens. It allows you to precisely control the colors in your projects and create visually
appealing designs.
RGBA Color Values
RGBA color values are an extension of RGB color values with an Alpha channel - which specifies the opacity for a color.
An RGBA color value is specified with:
rgba(red, green, blue, alpha)
The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all)
Digital Imaging: RGBA is used in image editing software to manage layers and transparency effects.
Graphics and Animation: RGBA is essential for creating smooth transitions and overlays in graphics and animations.
Why Use RGBA?
The alpha channel in RGBA allows for more flexibility in design by enabling transparency. This is particularly useful for creating overlays,
shadows, and other effects that require varying levels of opacity.
Conclusion
Understanding the RGBA color model is crucial for web developers and designers who want to create visually appealing and dynamic
designs. It provides an additional layer of control over color transparency, enhancing the overall user experience.
The CSS function rgb() has wide The CSS function rgba() may have limited support in the older
browser support. browser.
The opacity of the color cannot be The opacity of the color can be easily controlled by specifying the
specified using this color format. opacity in terms of a parameter.
The HEX color model is another way to represent colors in web design and digital imaging. HEX stands for hexadecimal, a base-16 number
system. Here’s a detailed explanation:
What is HEX?
HEX color codes are six-digit codes that represent colors using the hexadecimal number system. Each pair of digits in the code
corresponds to the intensity of red, green, and blue components of the color.
Color Representation
Here are some examples of HEX color codes:
Web Design: HEX codes are widely used in CSS to specify colors.
Digital Imaging: HEX codes are used in image editing software to manage colors.
Graphics and Animation: HEX codes are essential for creating precise color schemes in graphics and animations.
Why Use HEX?
The HEX color model is popular because it is compact and easy to read. It is also widely supported in web development and design tools.
HSL Color Fomat
HSL stands for Hue, Saturation, and Lightness respectively. This format uses the cylindrical coordinate system.
Hue: Hue is the degree of the color wheel. Its value lies between 0 to 360 where 0 represents red, 120 represents green and 240
represents blue color.
Saturation: It takes a percentage value, where 100% represents completely saturated, while 0% represents completely
unsaturated (gray).
Lightness: It takes percentage value, where 100% represents white, while 0% represents black.
Creating hyperlinks
ng hyperlinks
HTML links, or hyperlinks, connect web pages and are created using the `<a>` tag with the `href` attribute. They enable users to
navigate between pages or resources. Links can be text, images, or other elements, enhancing web navigation and interactivity. Users
can click on links to navigate between different pages or resources.
Note: A hyperlink can be represented by an image or any other HTML element, not just text.
By default, links will appear as follows in all browsers:
An unvisited link is underlined and blue
A visited link is underlined and purple
An active link is underlined and red
The most important attribute of the <a> element is the href attribute, which indicates the link's destination.
The link text is the part that will be visible to the reader.
Clicking on the link text, will send the reader to the specified URL address
Tip: If the <a> tag has no href attribute, it is only a placeholder for a hyperlink.
Advanced Features
Anchor Links: Link to a specific part of the same page using an ID.
Absolute URL: An absolute URL contains all the information needed to locate a resource. This includes the protocol (e.g., HTTP, HTTPS),
the domain name, and the path. It's a complete address that works no matter where the hyperlink is placed.
Example: [Link]
Relative URL: A relative URL, on the other hand, is a partial address that’s relative to the current page's URL. It doesn’t include the
protocol or domain name and is often used within the same website to link to another page or resource.
Example: /path/to/resource (assuming the base URL is [Link]
Differences:
Feature Absolute URL Relative URL
Completen Fully complete URL, with protocol and
Partial URL, missing protocol and domain
ess domain name
Can be used anywhere, regardless of the Used within the same website, dependent on the
Usage
current URL base URL
Example [Link] /path/to/resource
Document fragments
It's possible to link to a specific part of an HTML document, known as a document fragment, rather than just to the top of the document.
To do this you first have to assign an id attribute to the element you want to link to. It normally makes sense to link to a specific heading,
so this would look something like the following:
Then to link to that specific id, you'd include it at the end of the URL, preceded by a hash/pound symbol (#), for example:
<p>
Want to write us a letter? Use our
<a href="[Link]#Mailing_address">mailing address</a>.
</p>
You can even use the document fragment reference on its own to link to another part of the current document:
download filename Specifies that the target will be downloaded when a user clicks
on the hyperlink
href URL Specifies the URL of the page the link goes to
ping list_of_URLs Specifies a space-separated list of URLs to which, when the link
is followed, post requests with the body ping will be sent by the
browser (in the background). Typically used for tracking.
referrerpolicy no-referrer Specifies which referrer information to send with the link
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin-when-cross-origin
unsafe-url
rel alternate Specifies the relationship between the current document and
author the linked document
bookmark
external
help
license
next
nofollow
noreferrer
noopener
prev
search
tag
Email links
It's possible to create links or buttons that, when clicked, open a new outgoing email message rather than linking to a resource or page.
This is done using the <a> element and the mailto: URL scheme.
Use the mailto: scheme inside the href attribute to create a link that opens the user's email program
In fact, the email address is optional. If you omit it and your href is "[Link] a new outgoing email window will be opened by the user's
email client with no destination address. This is often useful as "Share" links that users can click to send an email to an address of their
choosing.
We can also include the cc, bcc, subject and body.
IMG
The <img> tag is used to embed an image in an HTML page. This is a void element
Images are not technically inserted into a web page; images are linked to web pages. The <img> tag creates a holding space for the
referenced image.
The <img> tag has two required attributes:
src - Specifies the path to the image
alt - Specifies an alternate text for the image, if the image for some reason cannot be displayed
Note: Also, always specify the width and height of an image. If width and height are not specified, the page might flicker while the image
loads.
Tip: To link an image to another document, simply nest the <img> tag inside an <a> tag.
Note: Search engines also read image filenames and count them towards SEO. Therefore, you should give your image a descriptive
filename; [Link] is better than [Link].
Never point the src attribute at an image hosted on someone else's website without permission. This is called "hotlinking".
src attribute:
The src attribute in <img> tag specifies the image’s location. If the URL is correct, the browser retrieves and displays the image;
otherwise, it shows a broken link icon.
Alternative text
The next attribute we'll look at is alt. Its value is supposed to be a textual description of the image, for use in situations where the image
cannot be seen/displayed or takes a long time to render because of a slow internet connection.
The easiest way to test your alt text is to purposely misspell your filename.
IMAGE MAP
Creating an image map in HTML allows you to define clickable areas within an image.
Insert the Image: Use the <img> tag to display your image and add the usemap attribute to link it to the image map.
<img src="[Link]" alt="Description" usemap="#image-map">
The usemap value starts with a hash tag # followed by the name of the image map, and is used to create a relationship between the
image and the image map.
Define the Image Map: Use the <map> tag to create the image map and give it a name that matches the usemap attribute.
<map name="image-map">
<!-- Define clickable areas here -->
</map>
The Areas
Then, add the clickable areas.
A clickable area is defined using an <area> element.
Shape
You must define the shape of the clickable area, and you can choose one of these values:
rect - defines a rectangular region
circle - defines a circular region
poly - defines a polygonal region
default - defines the entire region
You must also define some coordinates to be able to place the clickable area onto the image.
Shape="rect"
The coordinates for shape="rect" come in pairs, one for the x-axis and one for the y-axis.
So, the coordinates 34,44 is located 34 pixels from the left margin and 44 pixels from the top
The coordinates 270,350 is located 270 pixels from the left margin and 350 pixels from the top
Shape="circle"
To add a circle area, first locate the coordinates of the center of the circle: 337,300
Then specify the radius of the circle: 44 pixels
Shape="poly"
The shape="poly" contains several coordinate points, which creates a shape formed with straight lines (a polygon).
This can be used to create any shape.
Like maybe a croissant shape!
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="[Link]">
<area shape="circle" coords="337,300,44" alt="Coffee" href="[Link]">
<area shape="poly" coords="25,25,75,75,25,125" alt="Polygon" href="[Link]">
</map>
PICTURE ELEMENT
The <picture> element in HTML is a powerful tool for responsive web design, allowing you to specify multiple image sources for different
display scenarios.
Structure of the <picture> Element
The <picture> element contains one or more <source> elements and an <img> element. The browser will choose the most
appropriate image based on the conditions specified in the <source> elements.
<picture>
<source srcset="[Link]" media="(min-width: 800px)">
<source srcset="[Link]" media="(min-width: 500px)">
<img src="[Link]" alt="Description">
</picture>
Components
1. <picture> Element: Acts as a container for the <source> elements and the <img> element.
2. <source> Elements: Define different image sources and conditions for when each should be used.
o srcset Attribute: Specifies the URL of the image to be used.
o media Attribute: Defines the media condition (similar to a media query) that must be met for this source to be used.
3. <img> Element: Provides a default image and alt text. This is used if none of the <source> conditions are met or if the browser
does not support the <picture> element.
Use Cases
Art Direction: Serve different images for different screen sizes or orientations.
Format Support: Provide images in different formats to ensure compatibility with various browsers.
Responsive Images: Load different images based on the device’s screen size to save bandwidth and improve load times.
1. Bandwidth
If you have a small screen or device, it is not necessary to load a large image file. The browser will use the first <source> element with
matching attribute values, and ignore any of the following elements.
2. Format Support
Some browsers or devices may not support all image formats. By using the <picture> element, you can add images of all formats, and
the browser will use the first format it recognizes, and ignore any of the following elements.
Benefits
Flexibility: Allows for different images to be served based on screen size, resolution, and format support.
Performance: Helps in optimizing load times by serving appropriately sized images.
Compatibility: Ensures that a fallback image is always available for browsers that do not support the <picture> element.
TABLE
An HTML Table is an arrangement of data in rows and columns in tabular format. Tables are useful for various
tasks, such as presenting text information and numerical data. A table is a useful tool for quickly and easily finding
connections between different types of data. Tables are also used to create databases .
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
Dotted Table Borders
With the border-style property, you can set the appearance of the border.
dotted
dashed
solid
double
groove
ridge
inset
outset
none
hidden
To set the size of a specific column, add the style attribute on a <th> or <td> element:
To set the height of a specific row, add the style attribute on a table row element
HTML Table Headers
HTML tables can have headers for each column or row, or for many columns/rows.
8:00
9:00
10:00
11:00
12:00
13:00
8:00
9:00
10:00
11:00
12:00
DECEMBER
Table headers are defined with th elements. Each th element represents a table cell.
You can have a header that spans over two or more columns.
Name Age
Jill Smith 50
Eve Jackson 94
Table Caption
You can add a caption that serves as a heading for the entire table.
Monthly savings
Month Savings
January $100
February $50
HTML tables can adjust the padding inside the cells, and also the space between the cells.
With Padding
Cell padding is the space between the cell edges and the cell content.
To change the space between table cells, use the CSS border-spacing property on the table element
NAME
APRIL
2022
FIESTA
HTML Table - Colspan
To make a cell span over multiple columns, use the colspan attribute
Note: The value of the colspan attribute represents the number of columns to span.
To make a cell span over multiple rows, use the rowspan attribute:
Note: The value of the rowspan attribute represents the number of rows to span.
If you add a background color on every other table row, you will get a nice zebra stripes effect.
To style every other table row element, use the :nth-child(even) selector like this:
tr:nth-child(even) {
background-color: #D6EEEE;
}
Note: If you use (odd) instead of (even), the styling will occur on row 1,3,5 etc. instead of 2,4,6 etc.
th:nth-child(even),td:nth-child(even) {
background-color: rgba(150, 212, 212, 0.4);
}
The <colgroup> element should be used as a container for the column specifications.
Each group is specified with a <col> element.
The span attribute specifies how many columns that get the style.
The style attribute specifies the style to give the columns.
Note: The <colgroup> tag must be a child of a <table> element and should be placed before any other table elements,
like <thead>, <tr>, <td> etc., but after the <caption> element, if present.
There is only a very limited selection of CSS properties that are allowed to be used in the colgroup:
width property
visibility property
background properties
border properties
All other CSS properties will have no effect on your tables.
<th> Tag
Purpose: The <th> tag is used to define a header cell in a table. These cells are typically bold and centered by default.
Usage: It is used within a <tr> (table row) element.
Attributes: Common attributes include colspan, rowspan, scope, and abbr
<thead> Tag
Purpose: The <thead> tag is used to group a set of rows that contain the header information for a table. It helps in organizing the
table structure and can be useful for styling and accessibility.
Usage: It is used as a container for one or more <tr> elements that contain <th> elements. It is typically placed before
the <tbody> and <tfoot> elements.
Attributes: Common attributes include align, valign, and char
Key Differences
1. Function:
o <th>: Defines individual header cells.
o <thead>: Groups header rows together.
2. Placement:
o <th>: Placed within <tr> elements.
o <thead>: Placed directly within the <table> element, typically before <tbody> and <tfoot>.
3. Scope:
o <th>: Used for individual cells.
o <thead>: Used for a group of header rows.
4. Styling and Accessibility:
o <th>: Provides semantic meaning to individual cells.
o <thead>: Helps browsers and assistive technologies understand the structure of the table, making it easier to style and
navigate
A block-level element always starts on a new line, and the browsers automatically add some space (a margin) before and after the
element.
A block-level element in HTML is an element that starts on a new line and takes up the full width available, stretching out to the left and
right as far as it can. Here are some key characteristics and examples:
1. Starts on a New Line: Each block-level element begins on a new line, creating a distinct block of content.
2. Full Width: By default, block-level elements take up the entire width of their parent container.
3. Can Contain Other Elements: Block-level elements can contain other block-level elements and inline elements.
4. Vertical Layout: They stack vertically, one after the other.
Common Block-Level Elements
Block-level elements are essential for structuring and organizing content on a webpage. They help create a clear and readable layout by
stacking content vertically and taking up the full width of their container
You can style block-level elements using CSS to control their appearance, such as width, height, margins, padding, and borders.
INLINE ELEMENT
An inline element in HTML is an element that does not start on a new line and only takes up as much width as necessary. Here are some
key characteristics and examples:
1. Does Not Start on a New Line: Inline elements flow within the content and do not break the line.
2. Takes Up Only Necessary Width: They occupy only the space required by their content.
3. Can Contain Other Inline Elements: Inline elements can contain other inline elements but not block-level elements.
4. Part of the Text Flow: They are part of the text flow, meaning they align with the surrounding text.
Inline elements are essential for formatting and styling specific parts of your content without disrupting the flow of text. They are used
within block-level elements to enhance the presentation and functionality of your webpage.
You can style inline elements using CSS to control their appearance, such as color, font, and background.
Key Differences
1. Layout:
o Block-Level: Starts on a new line and takes up the full width.
o Inline: Does not start on a new line and only takes up as much width as necessary.
2. Containment:
o Block-Level: Can contain both block-level and inline elements.
o Inline: Can only contain other inline elements.
3. Usage:
o Block-Level: Used for larger sections of content and layout structuring.
o Inline: Used for smaller pieces of content within block-level elements.
Inline elements allow other inline elements to sit Block elements doesn’t allow other elements to sit
behind. behind
Do not cause line breaks. Cause line breaks before and after the element.
CLASS AND ID
The class attribute in HTML is used to assign one or more class names to an HTML element. These class names can then be used to apply
CSS styles or manipulate the element with JavaScript. you can use this class in CSS with a specific class, write a period (.) character,
followed by the name of the class for selecting elements.
1. Styling with CSS: The class attribute allows you to apply specific styles to elements. By defining a class in your CSS, you can style
multiple elements consistently.
2. JavaScript Manipulation: You can use JavaScript to select and manipulate elements with a specific class.
Note: You can use class attribute on any HTML element. The class name is case-sensitive.
You can use multiple class names (more than one) with HTML elements. These class names must be separated by a space.
The id attribute in HTML is used to assign a unique identifier to an HTML element. This identifier must be unique within the entire HTML
document, meaning no two elements can share the same id. Here’s a detailed explanation:
1. Styling with CSS: The id attribute allows you to apply specific styles to an element. By defining an id in your CSS, you can style that
particular element uniquely.
2. JavaScript Manipulation: You can use JavaScript to select and manipulate elements with a specific id.
3. Linking and Navigation: The id attribute can be used to create bookmarks within a page, allowing users to jump to specific
sections.
Note: In the Cascading Style sheet (CSS), we can easily select an element with the specific id by using the # symbol followed by id.
Key Differences
1. Uniqueness:
o class: Can be applied to multiple elements.
o id: Must be unique within the document.
2. CSS Selectors:
o class: Selected with a dot (.).
o id: Selected with a hash (#).
3. JavaScript Access:
o class: Accessed with getElementsByClassName.
o id: Accessed with getElementById.
4. Use Cases:
o class: Ideal for styling multiple elements with the same style or for grouping elements for JavaScript manipulation.
o id: Ideal for targeting a single, unique element for styling or JavaScript manipulation.
IFRAME
The <iframe> element in HTML is used to embed another HTML document within the current document in the rectangular region.. This
can be useful for displaying content from other websites, such as videos, maps, or other web pages.
The webpage content and iframe contents can interact with each other using JavaScript.
HTML Iframe is used to display a nested webpage (a webpage within a webpage). The HTML <iframe> tag defines an inline frame, hence
it is also called as an Inline frame.
Supported Attributes:
Attributes Description
allowpaymentreq
Enables payment requests for content inside the <iframe>.
uest
Specifies the name of the <iframe> for targeting its content or for
name
referencing it in JavaScript.
sandbox Specifies an extra set of restrictions for the content in the <iframe>.
Attributes Description
srcdoc Specifies the HTML content of the page to display in the <iframe>.
Security Considerations
Cross-Origin Content: Be cautious when embedding content from other domains, as it can pose security risks.
Sandboxing: Use the sandbox attribute to apply restrictions to the iframe content
<iframe src="[Link] sandbox="allow-scripts allow-same-origin"></iframe>
<!DOCTYPE html>
<html>
<head>
<title>Iframe Example</title>
</head>
<body>
<h1>Embedding a YouTube Video</h1>
<iframe width="560" height="315" src="[Link] title="YouTube video player"
frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
</body>
</html>
Non-semantic elements:
Non-semantic elements in HTML are those that do not provide any information about the content they contain. They are used
primarily for layout and styling purposes, without conveying any specific meaning or structure. Here are some key points and
examples:
Characteristics of Non-Semantic Elements
1. No Meaning: Non-semantic elements do not describe the content they contain.
2. Layout and Styling: They are often used to group content together for styling or layout purposes.
3. Require Additional Attributes: To make their purpose clear, they often need additional attributes like class or id.
Common Non-Semantic Elements
<div>: A generic container for flow content. It has no effect on the content or layout until styled using CSS.
<span>: A generic container for inline content. It is used to group inline elements for styling purposes.
Semantic VS Non-semantic
Key Differences
1. Meaning:
o Semantic Elements: Provide meaning and context about the content.
o Non-Semantic Elements: Do not provide any inherent meaning.
2. Usage:
o Semantic Elements: Used to structure content meaningfully.
o Non-Semantic Elements: Used for layout and styling without conveying content meaning.
3. Accessibility and SEO:
o Semantic Elements: Enhance accessibility and SEO.
o Non-Semantic Elements: Do not contribute to accessibility or SEO.
HTML ENTITIES
HTML entities are special characters that have a specific meaning in HTML and are used to display or represent certain
characters, symbols, or special characters in a web page. They are particularly useful for displaying characters that are
reserved in HTML or not easily typed on a keyboard.
HTML entities start with an ampersand (&) and end with a semicolon (;). There are two types of entities:
Entity Names: These are easier to remember and use. &entity_name;
Entity Numbers: These can be either decimal or hexadecimal. &#entity_number;
Reserved Characters
These characters are either reserved for HTML or those which are not present in the basic keyboard & can’t use them directly. Some of
the reserved characters representations are given below:
Reserved Character Entity Name
& &
< <
> >
Reserved Character Entity Name
“ "
Other Characters
Some characters that aren’t available directly on our keyboard, therefore such an entity can be used to represent it by using
their entity number. These keywords are directly not available to type, we need to specify their entity number. Here #x
before the numbers represents the hexadecimal representation.
Character Entities
≥ ≥
© ©
€ €
∃ ∃
Non-breaking Space
It is used to provide space that will not break into a new line. This HTML entity is represented by that will separate the
2 words & will stick together without breaking it into a new line. We can also use the non-breaking space for preventing the
browsers from truncating spaces in HTML pages. The non-breaking hyphen (-) is used to define a hyphen character (-) that
does not break into a new line.
Example
12:00 PM
256 km/h
If we use to write 10 spaces in our text, then the browser will remove 9 of them. In order to add real spaces in our text, we
can use the character entity
̀ a à à
́ a á á
̂ a â â
̃ a ã ã
̀ O Ò Ò
́ O Ó Ó
̂ O Ô Ô
̃ O Õ Õ
EMBEDDING AUDIO & VIDEO
Embedding Audio
To embed audio in HTML, use the <audio> element. You can include multiple sources to ensure compatibility with different
browsers.
<audio controls>
<source src="audiofile.mp3" type="audio/mpeg">
<source src="[Link]" type="audio/ogg">
Your browser does not support the audio element.
</audio>
Attributes
controls: Adds audio controls like play, pause, and volume.
autoplay: Starts playing the audio automatically.
loop: Loops the audio.
muted: Mutes the audio by default.
Embedding Video
To embed video in HTML, use the <video> element. Similar to audio, you can include multiple sources for compatibility.
Attributes
controls: Adds video controls like play, pause, and volume.
autoplay: Starts playing the video automatically.
loop: Loops the video.
muted: Mutes the video by default.
poster: Specifies an image to be shown while the video is downloading or until the user hits the play button.
HTML FORMS
An HTML form is used to collect user input. The user input is most often sent to a server for processing.
The HTML <form> element is used to create an HTML form for user input.
The <form> element is a container for different types of input elements, such as: text fields, checkboxes, radio buttons,
submit buttons, etc.
Tip: If the action attribute is omitted, the action is set to the current page.
Notes on POST:
Appends the form data inside the body of the HTTP request (the submitted form data is not shown in the URL)
POST has no size limitations, and can be used to send large amounts of data.
Form submissions with POST cannot be bookmarked.
Visible Values:
Use the size attribute to specify the number of visible values:
Note: Always specify the type attribute for the button element. Different browsers may use different default types for the
button element.
The <fieldset> and <legend> Elements
The <fieldset> element is used to group related data in a form.
The <legend> element defines a caption for the <fieldset> element.
I have a bike
I have a car
I have a boat
Input Restrictions
Here is a list of some common input restrictions:
Attribute Description
checked Specifies that an input field should be pre-selected when the page loads (for type="checkbox" or
type="radio")
disabled Specifies that an input field should be disabled
Note: Input restrictions are not foolproof, and JavaScript provides many ways to add illegal input. To safely restrict input, it
must also be checked by the receiver (the server)!
Anchor vs Link
Async:
Execution: Downloads the script asynchronously while the HTML continues to parse. Executes the script as soon as it'
s downloaded, without waiting for the HTML parsing to complete.
Use Case: Useful for independent scripts that don’t rely on other scripts or DOM content.
Defer:
Execution: Downloads the script asynchronously while the HTML continues to parse but delays execution until after th
e HTML is fully parsed.
Use Case: Ideal for scripts that need to be executed after the complete HTML is available but before the DOMContentL
oaded event.
Summarized Differences:
Normal: Blocks HTML parsing.
Async: Doesn't block HTML parsing; executes as soon as possible.
Defer: Doesn't block HTML parsing; executes after parsing is complete.
<h1> Tag:
Purpose: Represents the most important heading on the page.
Usage: Used for titling sections or the main title of the document.
<header> Tag:
Purpose: Represents a container for introductory content or navigational links.
Usage: Can contain headings, logos, and other introductory elements.