Basic HTML
Basic HTML
=>INTRODUCTION TO HTML
Introduction To HTML
Hypertext
Stands Cascading
Markup JavaScript
for Style Sheets
Language
Defines
content Defines Adds
and styles and interactivity
Purpose
structure layouts for and behavior
of web web pages to web pages
pages
Defines
Adds
content Enhances
functionality
and the
Role and
structure presentation
interactivity
of web of web pages
to web pages
pages
<html>,
<head>, if/else
color, font,
<body>, statements,
Examples margin,
<p>, loops, event
padding, etc.
<img>, handlers, etc.
etc.
Output :
Output
=>META TAGS
Meta Tags
Output :
Output
=>HTML ELEMENTS
HTML Elements
Example: <span
Example: <p>This is a
style="color: blue;">Hello
paragraph.</p>
World!</span>
4. List Tag :
There are three types of lists that can be used to
display information in a structured way. These are:
(I) Ordered List (<ol>): An ordered list is a list of items
where each item is numbered. It is created using
the <ol> tag.
Syntax:
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
(II) Unordered List (<ul>): An unordered list is a list of
items where each item is bulleted. It is created using
the <ul> tag.
Syntax:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
(III) Definition List (<dl>): A definition list is a list of
terms and their corresponding definitions. It is created
using the <dl> tag.
Syntax:
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
<dt>Term 3</dt>
<dd>Definition 3</dd>
</dl>
Note: In the definition list, <dt> tag is used for the
term and <dd> tag is used for its definition.
The type attribute in the list tag (<ul> and <ol>) is used
to define the type of list marker that should be used for
each list item. There are several values that can be
used for the type attribute:
• For ordered lists (<ol>), the type attribute can be
used to specify the numbering style of the list. The
default value is "1", which is for decimal
numbering. Other possible values are "A" for
uppercase alphabetical numbering, "a" for
lowercase alphabetical numbering, "I" for
uppercase Roman numerals, and "i" for lowercase
Roman numerals.
• For unordered lists (<ul>), the type attribute can
be used to specify the type of bullet or marker that
should be used for each list item. The default value
is "disc", which is a solid bullet. Other possible
values are "circle" for a hollow circle, "square" for
a solid square, and "none" for no bullet or marker.
5. Comment :
Comments are used to add notes or explanations to a
section of code. These comments are not displayed in
the browser but can be viewed by viewing the page
source code.
The syntax for adding comments is:
<!-- This is a comment -->
Anything between <!-- and --> is treated as a comment
and is ignored by the browser.
6. Bold Tag :
The <b> tag is used to define text in boldface. The text
enclosed within the <b> and </b> tags will appear in
bold format.
Syntax:
<b>Text to be bolded</b>
7. Italics Tag :
The "italics tag" is called the <i> tag, which stands for
"italic". This tag is used to indicate that the text within
the tags should be rendered in italic style. The syntax
for the <i> tag is:
<i>Italicized text</i>
8. Underline Tag :
The <u> tag is used to underline text. Here is the syntax
for the <u> tag:
<u>Underlined text</u>
9. Strikethrough Tag :
The <s> tag or <strike> tag is used to create a
strikethrough effect on the text. It is typically used to
show that a particular text has been deleted or is no
longer valid.
Syntax:
<s>Text to be striked through</s>
10. Superscript Tag :
The superscript tag is used to represent a superscript
text. It is often used to denote exponents, footnotes,
mathematical equations, etc. The syntax for
the superscript tag is:
<sup>Superscript Text</sup>
11. Subscript Tag :
The subscript tag is used to format text in a subscript
style. It is commonly used to write chemical formulas
or mathematical expressions that require the use of a
subscript. The syntax for the subscript tag is as follows:
<sub>text</sub>
12. Small Text Tag :
The <small> tag is used to define smaller text. It is
often used to display small print information such as
copyright, legal disclaimers, and other similar text.
The syntax for the <small> tag is as follows:
<small>Smaller Text</small>
13. Big Text Tag :
The <big> tag is used to define text that should be
displayed in a bigger font size than the surrounding
text. The syntax for the <big> tag is as follows:
<big>Text to be displayed in bigger font size</big>
14. Highlight Tag :
The <mark> tag is used to highlight text. It is often used
to indicate search results, keywords, or other
significant text on a web page. The syntax for
the <mark> tag is as follows:
<mark>Highlighted Text</mark>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Meta Tags</title>
<meta name = "author" content="GFG">
<meta name = "description" content="This is a
description">
<meta name = "keywords" content= "Movies,top 50
movies,gfg">
</head>
<body>
<h1>This is heading1</h1>
<h2>This is heading2</h2>
<h3>This is heading3</h3>
<h4>This is heading4</h4>
<h5>This is heading5</h5>
<h6>This is heading1</h6>
<ul>
<li> list 1</li>
<li> list 2</li>
<li> list 3</li>
</ul>
<ol type="a">
<li> list 1</li>
<li> list 2</li>
<li> list 3</li>
</ol>
<p>This is a <strong>pg</strong> in
<b>bold</b>.</p>
</body>
</html>
Output :
Output
Output
=>MULTIMEDIA TAGS
Multimedia Tags
</video>
In this syntax, the poster attribute is used to specify an
image that will be displayed before the video starts
playing.
b) The autoplay attribute, on the other hand, tells the
browser to start playing the video automatically as
soon as it is loaded. It can be added as follows:
<video src="video.mp4" autoplay></video>
3. Audio Tag :
The audio tag in HTML is used to embed audio files
directly on a webpage. It allows developers to add
audio files in various formats such as MP3, WAV, and
OGG to their web pages. The audio tag supports the
use of controls such as play, pause, and volume
adjustment, which can be added using attributes such
as autoplay, controls, and loop. The audio tag can also
be used in conjunction with JavaScript to create
interactive audio players and custom audio controls.
The syntax for the audio tag is:
<audio src="audio_file.mp3" controls></audio>
The src attribute specifies the URL of the audio file to
be played, and the controls attribute displays the built-
in controls for the user to play, pause, and adjust the
volume of the audio. Additional attributes can also be
added to the audio tag for customization purposes.
4. Object Tag :
The <object> tag in HTML is used to embed an external
resource into a web page, such as an image, video,
audio, PDF, or Flash animation. The resources are
usually multimedia files or plugins for web browsers.
The <object> tag contains several attributes, including
data, type, width, height, and classid, which are used to
specify the source and display properties of the object.
The syntax for the object tag:
<object data="url" type="mime/type">
<!-- fallback content -->
</object>
The data attribute specifies the URL of the resource to
be embedded, and the type attribute specifies the
MIME type of the resource.
Inside the object tag, you can include any kind of
fallback content in case the media file cannot be
loaded or displayed. For example, you can include text
or an image that describes the content of the media
file.
5. Embedded Tag :
The <iframe> tag is an example of an embedded tag in
HTML. It is used to embed a webpage or a portion of a
webpage into another HTML document. The src
attribute specifies the URL of the webpage to be
embedded. Other attributes such as width, height,
scrolling, and frameborder can be used to customize
the appearance and behavior of the embedded content
. The <iframe> tag is commonly used for displaying
content from other websites, embedding videos or
maps, and creating a layout for a webpage that
includes multiple sections.
The syntax for the <iframe> tag is:
<iframe src="url" width="value"
height="value"></iframe>
• The src attribute specifies the URL of the
document to be embedded.
• The width attribute specifies the width of the
embedded document.
• The height attribute specifies the height of the
embedded document.
Steps for embedding a YouTube video using an iframe:
1. Go to the YouTube website and find the video you
want to embed.
2. Click on the "Share" button located beneath the
video.
3. Click on the "Embed" button in the share menu.
4. Choose the video size and other customization
options you prefer.
5. Copy the iframe code generated by YouTube.
6. Open your HTML document in a text editor.
7. Paste the copied iframe code into the section of
your HTML document where you want the video to
appear.
8. Save your HTML document and open it in a web
browser to test the video playback.
Example :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Multimedia</title>
</head>
<body>
<h1>Multimedia Tags</h1>
<audio controls>
<source
src="./MA_DaniilDavydov_NeonAeon_Main.wav">
</audio>
<object data="./[Link]" type="application/pdf"
width="200px" height="200px"></object>
Output :
Output
=>IMAGE ELEMENTS
Image Elements
Image Tag :
The <img> tag is an HTML element used to embed
images in a web page. It is a self-closing tag, meaning it
does not require a closing tag. The <img> tag has
several attributes that define how the image should be
displayed, including the src attribute, which specifies
the URL of the image, the alt attribute, which provides
alternative text for the image, and the width and height
attributes, which specify the dimensions of the image.
The syntax for the img tag is as follows:
<img src="image_url" alt="alternative_text"
width="width_pixels" height="height_pixels">
Attributes :
1. Source : src (required) specifies the URL of the image
to be displayed.
2. Alternative Text : alt (required) provides an
alternative text description of the image for users who
are visually impaired or who have images disabled in
their browser.
3. Width : width (optional) specifies the width of the
image in pixels.
4. Height : height (optional) specifies the height of the
image in pixels.
5. Loading : The loading attribute in the <img> tag is
used to control how the browser loads and displays
images on a web page. It is a new attribute introduced
in HTML5 and is used to optimize the loading and
rendering of images to improve web page
[Link] loading attribute can have three
possible values:
• auto : This is the default value, and it tells the
browser to load the image as soon as possible.
• lazy : This tells the browser to delay loading the
image until it is about to come into the viewport or
the visible area of the web page. This can help
reduce the initial load time of the page and
improve performance, especially for images that
are located below the fold or not immediately
visible to the user.
• eager : This tells the browser to load the image
immediately, even if it is not currently visible in the
viewport. This can be useful for images that are
critical to the content or layout of the page and
need to be loaded and displayed as soon as
possible.
Note : It is an self closing tag.
Example :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Image Elements</title>
</head>
<body style="display: flex;flex-direction:column;">
<h1>Image Tag</h1>
<img src="./[Link]" alt="no image"
width="200px" height="200px"/>
<h1>Eager Loading</h1>
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="eager" />
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="eager"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="eager"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="eager"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px"loading="eager"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px"loading="eager"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px"loading="eager"/>
<h1>Lazy Loading</h1>
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="lazy" />
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="lazy"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="lazy"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px" loading="lazy"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px"loading="lazy"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px"loading="lazy"/>
<img src="./[Link]" alt="no image"
width="200px" height="200px"loading="lazy"/>
</body>
</html>
Output :
Output
Output
Explanation :
This is a basic HTML document with an image tag that
displays an image file called "[Link]". The tag
includes the "src" attribute, which specifies the path to
the image file. The "alt" attribute is also included,
which provides a text description of the image in case it
cannot be displayed.
In addition to the basic image tag, there are multiple
image tags included with the "loading" attribute set
to "eager" or "lazy". The "loading" attribute specifies
when and how the browser should load the
image. "Eager" loading means the browser will load the
image as soon as possible, while "lazy" loading means
the browser will wait until the image is needed before
loading it. This can help improve website performance
by reducing the amount of unnecessary resources
loaded on a page.
=>HYPERLINK
Hyperlink
</body>
</html>
Output :
Output
Explanation :
• The first line, <!DOCTYPE html>, is the document
type declaration. It tells the browser that the
document is an HTML5 document.
• The second line specifies that the document is in
the English language, using the lang attribute in
the <html> tag.
• Inside the <head> section, there are
several <meta> tags. These tags provide metadata
about the document. The first <meta> tag specifies
the character encoding used in the document
(UTF-8). The second <meta> tag specifies that the
document should be rendered in the latest version
of Internet Explorer. The third <meta> tag sets the
viewport width to the device's width and scales
the content accordingly.
• The <title> tag sets the title of the page, which
appears in the browser's title bar.
• Inside the <body> section, there is a
single <h1> heading tag that displays the text
"About page".
• Finally, there is an <a> tag that creates a hyperlink
to the GeeksforGeeks website. The href attribute
specifies the URL of the website, and the text
"Click Me" is displayed as the link text. When the
user clicks on this link, they will be taken to the
GeeksforGeeks website.
Types Of Hyperlink Tags :
1. Absolute Hyperlinks : Absolute hyperlinks use the
complete URL (Uniform Resource Locator) of the target
document or resource. They include the protocol (e.g.,
"[Link] or "[Link] domain name (e.g.,
"[Link]"), and the specific path or file name
(e.g., "/[Link]" or "/images/[Link]"). Absolute
hyperlinks point to a specific web address on the
internet.
2. Relative Hyperlinks : Relative hyperlinks use a
relative path to the target document or resource, which
is relative to the current web page's location. Relative
hyperlinks do not include the protocol or domain
name, but instead specify the path or file name of the
target document or resource relative to the current
web page's location. Relative hyperlinks are commonly
used when linking to documents or resources within
the same website or domain.
Example :
1. Home Page :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Hyperlinks</title>
</head>
<body>
<h1>Home page</h1>
<a href="[Link]
Me</a>
<a href="./[Link]">About</a>
<div>
<a href="#section1">Go to section1</a>
<a href="#section2">Go to section2</a>
<a href="#section3">Go to section3</a>
</div>
<div>
<h1 id="section1">section1</h1>
<p>Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Sit ducimus ullam laudantium neque
cupiditate? Itaque accusamus, placeat, porro mollitia
expedita tempora necessitatibus dolores libero eligendi
distinctio eum cupiditate delectus in quidem eaque
esse. Quaerat praesentium, alias fugiat consequatur
odio aliquam incidunt possimus non sequi quia aut
ratione. Labore, odit quod.</p>
</div>
<div>
<h1 id="section2">section2</h1>
<p>Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Sit ducimus ullam laudantium neque
cupiditate? Itaque accusamus, placeat, porro mollitia
expedita tempora necessitatibus dolores libero eligendi
distinctio eum cupiditate delectus in quidem eaque
esse. Quaerat praesentium, alias fugiat consequatur
odio aliquam incidunt possimus non sequi quia aut
ratione. Labore, odit quod.</p>
</div>
<div>
<h1 id="section3">section3</h1>
<p>Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Sit ducimus ullam laudantium neque
cupiditate? Itaque accusamus, placeat, porro mollitia
expedita tempora necessitatibus dolores libero eligendi
distinctio eum cupiditate delectus in quidem eaque
esse. Quaerat praesentium, alias fugiat consequatur
odio aliquam incidunt possimus non sequi quia aut
ratione. Labore, odit quod.</p>
</div>
</body>
</html>
Output :
Output
2. About Page :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Hyperlinks</title>
</head>
<body>
<h1>About page</h1>
<a href="[Link]
Me</a>
</body>
</html>
Output :
Output
Explanation :
• The first code creates a webpage with a hyperlink
to an external website
([Link] and two internal
hyperlinks to sections within the same page. The
internal hyperlinks are created using the anchor
tag <a> with the href attribute set to the ID of the
corresponding section within the page. The ID is
set using the id attribute on the section's header
tag (<h1> in this case).
• The second code creates a webpage with a single
hyperlink to an external website
([Link] on an "About"
page.
Target Attribute in Hyperlink Tag :
The target attribute is used to specify where the linked
document or resource should be displayed when a
hyperlink is clicked. It is used as an attribute within
the <a> (anchor) tag, which is used to create
[Link] target attribute can take several values,
including:
1. _self: The linked document or resource will be
loaded in the same frame or window as the current
web page. This is the default behavior if
the target attribute is not specified.
Example:
<a href="[Link] target="_self">Visit
Example Website</a>
2. _blank: The linked document or resource will be
loaded in a new, unnamed browser window or tab.
Example:
<a href="[Link] target="_blank">Visit
Example Website</a>
3. _parent: The linked document or resource will be
loaded in the parent frame or window of the current
web page, if the current web page is within a frameset
or iframe.
Example:
<a href="[Link]
target="_parent">Visit Example Website</a>
4. _top: The linked document or resource will be
loaded in the top-level browsing context, replacing any
frames or iframes that may be present.
Example:
<a href="[Link] target="_top">Visit
Example Website</a>
Example :
1. Target Page 1 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 1</title>
</head>
<body>
<a href="[Link]
target="_blank"></a>
<a href="[Link]
target="_parent"></a>
<a href="[Link]
target="_self"></a>
<a href="[Link]
target="_top"></a>
</body>
</html>
2. Target Page 2 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 2</title>
</head>
<body>
<h1>This is page 2</h1>
<iframe src="./[Link]" width="500px"
height="500px"></iframe>
</body>
</html>
3. Target Page 3 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 3</title>
</head>
<body>
<h1>This is page 3</h1>
<iframe src="./[Link]" width="500px"
height="500px"></iframe>
</body>
</html>
4. Target Page 4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 4</title>
</head>
<body>
<a href="[Link]
target="_self">Geeks For Geeks</a>
</body>
</html>
Output :
Output
Output
Output
Explanation :
These codes are related to the use of
the target attribute in hyperlinks and iframes.
In the first HTML code block, there are four hyperlinks
that have different values set for the target attribute.
The target attribute determines where the linked
document should be displayed when the user clicks on
the hyperlink. The values used in this code block are:
• _blank: The linked document will be displayed in a
new window or tab.
• _parent: The linked document will be displayed in
the parent frame of the current frame or in the
parent window if there is no parent frame.
• _self: The linked document will replace the current
document in the same frame or window.
• _top: The linked document will replace the current
document and will be displayed in the full body of
the window.
In the second HTML code block, there is an iframe that
embeds the content of the third HTML code block.
The src attribute specifies the source URL of the
document to be embedded, and
the width and height attributes define the size of the
iframe. When the user loads the second HTML
document, the embedded document from the third
HTML code block is displayed within the iframe.
In the third HTML code block, there is another iframe
that embeds the content of the fourth HTML code
block. The embedded document contains a hyperlink
with the target attribute set to _self. When the user
clicks on the hyperlink, the linked document will
replace the current document in the same frame or
window.
In the fourth HTML code block, there is a hyperlink
with the target attribute set to _self. This means that
when the user clicks on the hyperlink, the linked
document located at
"[Link] will replace the
current document in the same frame or window. The
linked document will load in the same browser window
or frame where the hyperlink is clicked, and it will
replace the content of the current document with the
content of the linked document.
The text "Geeks For Geeks" is the visible link text that
will be displayed to the user. When the user clicks on
this link, the browser will navigate to the URL specified
in the href attribute, which is
"[Link] The target
attribute _self ensures that the linked document will be
loaded in the same window or frame where the
hyperlink is clicked, and the current document will be
replaced by the content of the linked document.
=>CONTAINERS AND LIST
Hyperlink
</body>
</html>
Output :
Output
Explanation :
• The first line, <!DOCTYPE html>, is the document
type declaration. It tells the browser that the
document is an HTML5 document.
• The second line specifies that the document is in
the English language, using the lang attribute in
the <html> tag.
• Inside the <head> section, there are
several <meta> tags. These tags provide metadata
about the document. The first <meta> tag specifies
the character encoding used in the document
(UTF-8). The second <meta> tag specifies that the
document should be rendered in the latest version
of Internet Explorer. The third <meta> tag sets the
viewport width to the device's width and scales
the content accordingly.
• The <title> tag sets the title of the page, which
appears in the browser's title bar.
• Inside the <body> section, there is a
single <h1> heading tag that displays the text
"About page".
• Finally, there is an <a> tag that creates a hyperlink
to the GeeksforGeeks website. The href attribute
specifies the URL of the website, and the text
"Click Me" is displayed as the link text. When the
user clicks on this link, they will be taken to the
GeeksforGeeks website.
Types Of Hyperlink Tags :
1. Absolute Hyperlinks : Absolute hyperlinks use the
complete URL (Uniform Resource Locator) of the target
document or resource. They include the protocol (e.g.,
"[Link] or "[Link] domain name (e.g.,
"[Link]"), and the specific path or file name
(e.g., "/[Link]" or "/images/[Link]"). Absolute
hyperlinks point to a specific web address on the
internet.
2. Relative Hyperlinks : Relative hyperlinks use a
relative path to the target document or resource, which
is relative to the current web page's location. Relative
hyperlinks do not include the protocol or domain
name, but instead specify the path or file name of the
target document or resource relative to the current
web page's location. Relative hyperlinks are commonly
used when linking to documents or resources within
the same website or domain.
Example :
1. Home Page :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Hyperlinks</title>
</head>
<body>
<h1>Home page</h1>
<a href="[Link]
Me</a>
<a href="./[Link]">About</a>
<div>
<a href="#section1">Go to section1</a>
<a href="#section2">Go to section2</a>
<a href="#section3">Go to section3</a>
</div>
<div>
<h1 id="section1">section1</h1>
<p>Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Sit ducimus ullam laudantium neque
cupiditate? Itaque accusamus, placeat, porro mollitia
expedita tempora necessitatibus dolores libero eligendi
distinctio eum cupiditate delectus in quidem eaque
esse. Quaerat praesentium, alias fugiat consequatur
odio aliquam incidunt possimus non sequi quia aut
ratione. Labore, odit quod.</p>
</div>
<div>
<h1 id="section2">section2</h1>
<p>Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Sit ducimus ullam laudantium neque
cupiditate? Itaque accusamus, placeat, porro mollitia
expedita tempora necessitatibus dolores libero eligendi
distinctio eum cupiditate delectus in quidem eaque
esse. Quaerat praesentium, alias fugiat consequatur
odio aliquam incidunt possimus non sequi quia aut
ratione. Labore, odit quod.</p>
</div>
<div>
<h1 id="section3">section3</h1>
<p>Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Sit ducimus ullam laudantium neque
cupiditate? Itaque accusamus, placeat, porro mollitia
expedita tempora necessitatibus dolores libero eligendi
distinctio eum cupiditate delectus in quidem eaque
esse. Quaerat praesentium, alias fugiat consequatur
odio aliquam incidunt possimus non sequi quia aut
ratione. Labore, odit quod.</p>
</div>
</body>
</html>
Output :
Output
2. About Page :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Hyperlinks</title>
</head>
<body>
<h1>About page</h1>
<a href="[Link]
Me</a>
</body>
</html>
Output :
Output
Explanation :
• The first code creates a webpage with a hyperlink
to an external website
([Link] and two internal
hyperlinks to sections within the same page. The
internal hyperlinks are created using the anchor
tag <a> with the href attribute set to the ID of the
corresponding section within the page. The ID is
set using the id attribute on the section's header
tag (<h1> in this case).
• The second code creates a webpage with a single
hyperlink to an external website
([Link] on an "About"
page.
Target Attribute in Hyperlink Tag :
The target attribute is used to specify where the linked
document or resource should be displayed when a
hyperlink is clicked. It is used as an attribute within
the <a> (anchor) tag, which is used to create
[Link] target attribute can take several values,
including:
1. _self: The linked document or resource will be
loaded in the same frame or window as the current
web page. This is the default behavior if
the target attribute is not specified.
Example:
<a href="[Link] target="_self">Visit
Example Website</a>
2. _blank: The linked document or resource will be
loaded in a new, unnamed browser window or tab.
Example:
<a href="[Link] target="_blank">Visit
Example Website</a>
3. _parent: The linked document or resource will be
loaded in the parent frame or window of the current
web page, if the current web page is within a frameset
or iframe.
Example:
<a href="[Link]
target="_parent">Visit Example Website</a>
4. _top: The linked document or resource will be
loaded in the top-level browsing context, replacing any
frames or iframes that may be present.
Example:
<a href="[Link] target="_top">Visit
Example Website</a>
Example :
1. Target Page 1 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 1</title>
</head>
<body>
<a href="[Link]
target="_blank"></a>
<a href="[Link]
target="_parent"></a>
<a href="[Link]
target="_self"></a>
<a href="[Link]
target="_top"></a>
</body>
</html>
2. Target Page 2 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 2</title>
</head>
<body>
<h1>This is page 2</h1>
<iframe src="./[Link]" width="500px"
height="500px"></iframe>
</body>
</html>
3. Target Page 3 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 3</title>
</head>
<body>
<h1>This is page 3</h1>
<iframe src="./[Link]" width="500px"
height="500px"></iframe>
</body>
</html>
4. Target Page 4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
<title>Target 4</title>
</head>
<body>
<a href="[Link]
target="_self">Geeks For Geeks</a>
</body>
</html>
Output :
Output
Output
Output
Explanation :
These codes are related to the use of
the target attribute in hyperlinks and iframes.
In the first HTML code block, there are four hyperlinks
that have different values set for the target attribute.
The target attribute determines where the linked
document should be displayed when the user clicks on
the hyperlink. The values used in this code block are:
• _blank: The linked document will be displayed in a
new window or tab.
• _parent: The linked document will be displayed in
the parent frame of the current frame or in the
parent window if there is no parent frame.
• _self: The linked document will replace the current
document in the same frame or window.
• _top: The linked document will replace the current
document and will be displayed in the full body of
the window.
In the second HTML code block, there is an iframe that
embeds the content of the third HTML code block.
The src attribute specifies the source URL of the
document to be embedded, and
the width and height attributes define the size of the
iframe. When the user loads the second HTML
document, the embedded document from the third
HTML code block is displayed within the iframe.
In the third HTML code block, there is another iframe
that embeds the content of the fourth HTML code
block. The embedded document contains a hyperlink
with the target attribute set to _self. When the user
clicks on the hyperlink, the linked document will
replace the current document in the same frame or
window.
In the fourth HTML code block, there is a hyperlink
with the target attribute set to _self. This means that
when the user clicks on the hyperlink, the linked
document located at
"[Link] will replace the
current document in the same frame or window. The
linked document will load in the same browser window
or frame where the hyperlink is clicked, and it will
replace the content of the current document with the
content of the linked document.
The text "Geeks For Geeks" is the visible link text that
will be displayed to the user. When the user clicks on
this link, the browser will navigate to the URL specified
in the href attribute, which is
"[Link] The target
attribute _self ensures that the linked document will be
loaded in the same window or frame where the
hyperlink is clicked, and the current document will be
replaced by the content of the linked document.
=>TABLES
Tables
Output :
Output
Explanation :
This code is demonstrating how to create a table with
the use of the table, tr (table row), th (table header),
and td (table data/cell) [Link] CSS code is used to
style the table and its elements. The table tag has a
width of 100% and the border-collapse property is set
to collapse to remove the spaces between the cells.
The th tag is styled with a blue border of 1px, aqua
color and font size of 20px. The td tag is styled with a
blueviolet color and font size of 10px and a 1px blue
[Link] table has a header row that contains two
columns, "First Name" and "Last Name". The th tag is
used to define the table header cells. The table data is
filled in the rows with the td tag, where each tr tag
represents a new [Link] table has three rows with the
same data, "Avneet Kaur", in the two columns.
<table>
<thead>Tables</thead>
<tbody>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
<tr>
<td>Avneet</td>
<td>Kaur</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">footer</td></tr>
</tfoot>
<caption>My Table</caption>
</table>
</body>
</html>
Output :
Output
Explanation :
• The table tag is used to create a table, and
the thead, tbody, and tfoot tags are used to create
the table's header, body, and footer, respectively.
• The style tag contains CSS code that defines the
appearance of the table.
• The table tag's width is set to 100%, and its border
is collapsed.
• The th tag is used to define the table header cells'
appearance, which are colored aqua and have a
border of 1px solid blue. The font size is set to
20px.
• The td tag is used to define the table data cells'
appearance, which are colored blueviolet, have a
font size of 10px, are centered, and have a border
of 1px solid blue.
• The thead tag's background color is set to
antiquewhite, and the #alter id's background color
is set to aquamarine.
• The table's even rows are colored beige, and the
odd rows are colored blanchedalmond.
• The table contains a caption that says "My Table."
• The table contains ten rows, with two columns for
the first and last name.
• The table's footer contains one row with one cell
that spans two columns.
=>INPUT 1
Input I
<br><br>
<br><br>
<br><br>
<p>What is Your hobby?</p>
<input type="checkbox" name="hobby1"
value="Reading">
<label>Reading</label><br>
<input type="checkbox" name="hobby2"
value="Weading">
<label>Writing</label><br>
<br><br>
<input type="button" value="Click Me"
onclick="alert(2+2)">
<br><br>
<input type="color" name="bgcolor" value="#ffffff">
<br><br>
<input type="date" name="dob" max="2023-11-30"
min="2023-10-30" value="2023-11-01">
<br><br>
<input type="file" name="myfile" accept=".pdf,.jpg">
<br><br>
<input type="month" min="2023-10" value="2023-
11">
<br><br>
<input type="time" value="12:00:00"/>
<br><br>
<input type="datetime-local" value="2023-11-
10T12:00:00"/>
<br><br>
<input type="week" value="2023-W10"/>
<br><br>
<input type="number" value="10" min="4" max="20"
step="3" />
<br><br>
<label>Select Your Age</label>
<input type="range" min="0" max="120" value="20"
step="1"/>
</form>
</body>
</html>
Output :
Output
Output
Marked as Read
Report An Issue
=>INPUT 2
Input II
Output :
Output
=>FORM
Form
<br><br>
<label>What is your age ?</label>
<select name="userage" size="1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<br><br>
<textarea name="message" rows="10" cols="50"
style="width:100px;height:100px;max-
width:300px;min-width:150px;"></textarea>
<br><br>
<button type="button" onclick="alert('hey
there')">Don't Click</button>
<br><br>
<fieldset>
<legend>Login</legend>
<input type="text" name="email"
placeholder="enter your email" list="myname">
<datalist id="myname">
<option value="name1">name1</option>
<option value="name2">name2</option>
<option value="name3">name3</option>
</datalist>
<input type="password" name="pwd"
placeholder="enter your password">
<input type="submit" value="login"
formaction="/someotherpath"
formenctype="multipart/form-data"
formmethod="get" formtarget="_blank">
</fieldset>
</form>
<input type="submit" value="login"
form="myform1">
</body>
</html>
Output :
Output
Explanation :
The <form> tag defines a form that is used to collect
user input. It has several attributes:
• action="/submituserdata": Specifies the URL to
which the form data will be submitted.
• method="get": Specifies the HTTP method to be
used for submitting the form data. In this case, it is
set to "get", which means the form data will be
appended to the URL as query parameters.
• target="_blank": Specifies the target window or
frame where the form response will be displayed.
In this case, it is set to "_blank", which means the
form response will open in a new window.
• autocomplete="off": Specifies whether the form
should have autocomplete enabled or disabled. In
this case, it is set to "off", which means
autocomplete is disabled.
• id="myform1": Specifies a unique identifier for the
form, which can be used to reference the form in
JavaScript or other parts of the HTML document.
• enctype="multipart/form-data": Specifies the
encoding type for the form data. In this case, it is
set to "multipart/form-data", which is used for
uploading files.
Inside the <form> tag, there are several form elements:
1. <input> elements: These are used to collect user
input. There are three <input> elements in this form:
• One with type="text" and name="email": This is a
text input field where users can enter their email
address.
• One with type="password" and name="pwd": This
is a password input field where users can enter
their password.
• One with type="submit" and value="login": This is
a submit button that users can click to submit the
form data.
2. <select> element: This is a dropdown list where
users can select an option. It has the name attribute set
to "userage" and the size attribute set to "1", which
means it will display one option at a time.
3. <textarea> element: This is a multi-line text input
field where users can enter a longer message. It has
the name attribute set to "message" and
the rows and cols attributes set to control the size of
the textarea.
4. <button> element: This is a button that users can
click. It has the type attribute set to "button" and
an onclick attribute that specifies a JavaScript function
to be executed when the button is clicked. In this case,
it displays an alert with the message "hey there".
5. <fieldset> element: This is used to group related
form elements together. It has a <legend> element
inside that specifies a caption for the fieldset, which in
this case is "Login". Inside the fieldset, there are
two <input> elements:
• One with type="text" and name="email": This is a
text input field where users can enter their email
address. It also has a list attribute that references
a <datalist> element with the id "myname", which
provides suggestions for the input field.
• One with type="password" and name="pwd": This
is a password input field where users can enter
their password.
• There is also an <input> element
with type="submit", which is a submit button that
users can click to submit the form data. It has
additional attributes
formaction="/someotherpath", and
formenctype="multipart/form-data". These
attributes override the form-level action, method,
and enctype attributes for this specific submit
button. When this submit button is clicked, the
form data will be submitted to the URL specified in
the formaction attribute, using the encoding type
specified in the formenctype attribute, and the
HTTP method specified in the formmethod
attribute.
=>SEMANTIC HTML
Semantic HTML
</body>
</html>
Output :
Output
Marked as Read
Report An Issue