Unit 4 Web
Unit 4 Web
• Fundamentals of HTML5
HTML (Hypertext Markup Language) is the standard markup
language for creating and structuring web pages. It provides a set
of elements or tags that define the structure and content of a web
page. Here are some fundamental concepts and elements in HTML:
1) Root Elements
In HTML, the root element is the top-level element that encloses all
the content on a web page. The root element for HTML documents is
`<html>`. Here's a brief explanation of the root elements and their role
in an HTML document:
2. `<html>` Element:
▪ The `<html>` element is the root element of an HTML
document. All other elements are nested within it. It
contains two main sections: `<head>` and `<body>`.
▪ Example:
<!DOCTYPE html>
<html>
<head>
<!-- Head section content goes here -->
</head>
<body>
<!-- Body section content goes here -->
</body>
</html>
3. `<head>` Element:
▪ The `<head>` element contains meta-information about the
HTML document, such as the title, character set, linked
stylesheets, and metadata. It doesn't directly contribute to
the visible content of the page.
▪ Example:
<head>
<title>Your Title Here</title>
<!-- Other head section elements go here -->
</head>
4. `<body>` Element:
▪ The `<body>` element contains the main content of the HTML
document, including text, images, links, and other elements
that are visible in the browser.
▪ Example
<body>
<h1>Hello, World!</h1>
<p>This is a sample HTML document.</p>
<!-- Other body section elements go here -->
</body>
2) Metadata Elements
In HTML5, metadata elements are used to provide information about
the HTML document itself. This information is not directly displayed
on the web page but is crucial for browsers, search engines, and other
tools. Here are some key metadata elements in HTML5:
1. `<meta>` Element:
▪ The `<meta>` element is used to define metadata about an
HTML document. It is commonly used to set the character
encoding, viewport settings for responsive design, and other
information.
▪ Example (setting character encoding):
<meta charset="UTF-8">
• Example (viewport settings for responsive design):
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
• The `charset` attribute specifies the character encoding, and the
`viewport` meta tag is often used to control the page's
dimensions and scaling on different devices.
2. `<title>` Element:
• The `<title>` element is used to define the title of the HTML
document. The text within this element typically appears in the
browser's title bar or tab.
• Example:
<title>My Web Page</title>
3. `<base>` Element:
• The `<base>` element specifies the base URL/target for all
relative URLs in a document. It is helpful when you want to set
a default URL for all links and forms in the document.
• Example:
<base href="https://www.example.com/" target="_blank">
• In this example, all relative URLs will be resolved relative to
"https://www.example.com/" and links will open in a new tab.
4. `<link>` Element:
• The `<link>` element is used to link external resources to the
HTML document. It is commonly used to link stylesheets,
favicons, and other resources.
• Example (linking a stylesheet):
<link rel="stylesheet" href="styles.css">
• This example links an external CSS stylesheet to the HTML
document.
5. `<style>` Element:
• The `<style>` element can be used to embed CSS (Cascading
Style Sheets) directly within the HTML document.
• Example:
<style>
body {
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
</style>
• This example sets some basic styles for the document directly
within the HTML file.
1. `<header>` Element:
• The `<header>` element represents introductory content or a
group of navigational links. It typically contains headings,
logos, and other elements related to the document or section
it belongs to.
• Example:
<header>
<h1>My Website</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
2. `<nav>` Element:
• The `<nav>` element represents a section of navigation links,
such as menus or tables of contents.
• Example:
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
3. `<section>` Element:
• The `<section>` element represents a generic section of
content. It is often used to group related content together
and can have its own heading.
• Example:
<section>
<h2>Section Heading</h2>
<p>This is some content within the
section.</p>
</section>
4. `<article>` Element:
• The `<article>` element represents a self-contained piece of
content that could be distributed and reused independently,
such as a news article or blog post.
• Example:
<article>
<h2>Article Title</h2>
<p>Article content goes here.</p>
</article>
5. `<aside>` Element:
• The `<aside>` element represents content that is tangentially
related to the content around it, such as a sidebar or a pull
quote.
• Example:
<article>
<h2>Article Title</h2>
<p>Article content goes here.</p>
<aside>
<p>Related information or links.</p>
</aside>
</article>
6. `<footer>` Element:
• The `<footer>` element represents the footer of a section or a
page. It often contains metadata, copyright information, or
links to related resources.
• Example:
<footer>
<p>© 2023 My Website</p>
</footer>
These semantic sectioning elements help create a clearer document
structure, making it easier for both developers and assistive
technologies to understand the content and its relationships. Using
these elements appropriately enhances the accessibility and
maintainability of web pages.
4) Heading Elements
In HTML5, you can use the `<h1>` to `<h6>` elements to define
headings. These elements represent six levels of section headings,
with `<h1>` being the highest (most important) and `<h6>` being the
lowest.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>HTML5 Headings</title>
</head>
<body>
</body>
</html>
The `<h1>` element is used for the main heading of the page, and subsequent
heading levels (`<h2>`, `<h3>`, and so on) are used to represent subsections or
nested headings. It's important to use heading elements in a hierarchical and
meaningful way to structure your content properly for both users and search
engines.
5) Flow Elements
In HTML5, flow elements are elements that contribute to the
document's main content flow. These elements are used to structure
and organize the content of a webpage. Here are some common flow
elements in HTML5:
1. Paragraph (`<p>`):
<p>This is a paragraph.</p>
3. Anchor (`<a>`):
<a href="https://www.example.com">Visit Example.com</a>
4. List (`<ul>`, `<ol>`, `<li>`):
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
5. Images (`<img>`):
<img src="image.jpg" alt="Description of the image">
9. Division (`<div>`):
<div>This is a division. </div>
6) Phrasing Elements
In HTML5, phrasing elements are elements that define the text and its
inline-level semantics within the document. These elements are used
to markup and structure the text content. Here are some common
phrasing elements in HTML5:
3. Inline Images:
• Image (`<img>`): Embeds images.
<p>This is an <img src="image.jpg" alt="Description"> image.</p>
4. Code Elements:
• Code (`<code>`): Represents a single line of code.
<p>Use the <code>git clone</code> command to clone a
repository.</p>
6. Inline Quotes:
• Quote (`<q>`): Represents a short inline quotation.
<p>He said, <q>This is a short quote.</q></p>
8) Interactive Elements
In HTML5, interactive elements are used to create a dynamic and
engaging user experience by allowing users to interact with the
content. Here are some common interactive elements:
9. Anchor (`<a>`) with `href` attribute: When used with the `href`
attribute, anchors can link to different parts of the same document,
creating smooth scrolling effects.
<a href="#section2">Go to Section 2</a>
<!-- ... -->
<h2 id="section2">Section 2</h2>
form {
max-width: 600px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
}
button:hover {
background-color: #555;
}
</style>
</head>
<body>
<form>
<h2>CSE Department Admission Form</h2>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="gender">Gender:</label>
<select id="gender" name="gender" required>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
<label for="address">Address:</label>
<textarea id="address" name="address" rows="4" required></textarea>
<label for="marks">Percentage/CGPA:</label>
<input type="text" id="marks" name="marks" required>
<button type="submit">Submit</button>
</form>
</body>
</html>
Output:
HTML5 | Introduction
Introduction: HTML stands for Hyper Text Markup Language. It is used to
design web pages using a markup language. HTML is an abbreviation of Hypertext
and Markup language. Hypertext defines the link between the web pages. The
markup language is used to define the text document within the tag which defines
the structure of web pages. HTML 5 is the fifth and current version of HTML. It
has improved the markup available for documents and has introduced application
programming interfaces (API) and Document Object Model (DOM).
Features:
It has introduced new multimedia features which supports both audio and
video controls by using <audio> and <video> tags.
There are new graphics elements including vector graphics and tags.
Enrich semantic content by including <header> <footer>, <article>,
<section> and <figure> are added.
Drag and Drop- The user can grab an object and drag it further dropping it to
a new location.
Geo-location services- It helps to locate the geographical location of a client.
Web storage facility which provides web application methods to store data on
the web browser.
Uses SQL database to store data offline.
Allows drawing various shapes like triangle, rectangle, circle, etc.
Capable of handling incorrect syntax.
Easy DOCTYPE declaration i.e., <!doctype html>
Easy character encoding i.e., <meta charset=”UTF-8″>
Removed elements from HTML 5: There are many elements which are
depreciated from HTML 5 are listed below:
<acronym> <abbr>
<applet> <object>
Removed Elements Use Instead Elements
<basefont> CSS
<big> CSS
<center> CSS
<dir> <ul>
<font> CSS
<frame>
<frameset>
<noframes>
<isindex>
<tt> CSS
New Added Elements in HTML 5:
<article>: The <article> tag is used to represent an article. More
specifically, the content within the <article> tag is independent from the
other content of the site (even though it can be related).
<aside>: The <aside> tag is used to describe the main object of the web
page in a shorter way like a highlighter. It basically identifies the content
that is related to the primary content of the web page but does not
constitute the main intent of the primary page. The <aside> tag contains
mainly author information, links, related content and so on.
<figcaption>: The <figcaption> tag in HTML is used to set a caption to
the figure element in a document.
<figure>: The <figure> tag in HTML is used to add self-contained content
like illustrations, diagrams, photos or codes listing in a document. It is
related to main flow, but it can be used in any position of a document and
the figure goes with the flow of the document and if it is removed it
should not affect the flow of the document.
<header>: It contains the section heading as well as other content, such as
a navigation links, table of contents, etc.
<footer>: The <footer> tag in HTML is used to define a footer of HTML
document. This section contains the footer information (author
information, copyright information, carriers etc.). The footer tag is used
within body tag. The <footer> tag is new in the HTML 5. The footer
elements require a start tag as well as an end tag.
<main>: Delineates the main content of the body of a document or web
app.
<mark>: The <mark> tag in HTML is used to define the marked text. It is
used to highlight the part of the text in the paragraph.
<nav>: The <nav> tag is used to declaring the navigational section in
HTML documents. Websites typically have sections dedicated to
navigational links, which enables user to navigate the site. These links can
be placed inside a nav tag.
<section>: It demarcates a thematic grouping of content.
<details>: The <details> tag is used for the content/information which is
initially hidden but could be displayed if the user wishes to see it. This tag
is used to create interactive widget which user can open or close it. The
content of details tag is visible when open the set attributes.
<summary>: The <summary> tag in HTML is used to define a summary
for the <details> element. The <summary> element is used along with the
<details> element and provides a summary visible to the user. When the
summary is clicked by the user, the content placed inside the <details>
element becomes visible which was previously hidden. The <summary>
tag was added in HTML 5. The <summary> tag requires both starting and
ending tag.
<time>: The <time> tag is used to display the human-readable data/time.
It can also be used to encode dates and times in a machine-readable form.
The main advantage for users is that they can offer to add birthday
reminders or scheduled events in their calendars and search engines can
produce smarter search results.
<bdi>: The <bdi> tag refers to the Bi-Directional Isolation. It
differentiates a text from other text that may be formatted in different
direction. This tag is used when a user generated text with an unknown
direction.
<wbr>: The <wbr> tag in HTML stands for word break opportunity and is
used to define the position within the text which is treated as a line break
by the browser. It is mostly used when the used word is too long and there
are chances that the browser may break lines at the wrong place for fitting
the text.
<datalist>: The <datalist> tag is used to provide autocomplete feature in
the HTML files. It can be used with input tag, so that users can easily fill
the data in the forms using select the data.
<keygen>: The <keygen> tag in HTML is used to specify a key-pair
generator field in a form. The purpose of <keygen> element is to provide a
secure way to authenticate users. When a form is submitted then two keys
are generated, private key and public key. The private key stored locally,
and the public key is sent to the server. The public key is used to generate
client certificate to authenticate user in future.
<output>: The <output> tag in HTML is used to represent the result of a
calculation performed by the client-side script such as JavaScript.
<progress>: It is used to represent the progress of a task. It also defines
how much work is done and how much is left to download a task. It is not
used to represent the disk space or relevant query.
<svg>: It is the Scalable Vector Graphics.
<canvas>: The <canvas> tag in HTML is used to draw graphics on web
page using JavaScript. It can be used to draw paths, boxes, texts, gradient
and adding images. By default, it does not contain border and text.
<audio>: It defines the music or audio content.
<embed>: Defines containers for external applications (usually a video
player).
<source>: It defines the sources for <video> and <audio>.
<track>: It defines the tracks for <video> and <audio>.
<video>: It defines the video content.
Advantages:
All browsers supported.
More device friendly.
Easy to use and implement.
HTML 5 in integration with CSS, JavaScript, etc. can help build beautiful
websites.
Disadvantages:
Long codes have to be written which is time consuming.
Only modern browsers support it.
Supported Browsers: It is supported by all modern browsers.
Below examples illustrate the HTML 5 content.
Example 1:
<!DOCTYPE html>
<html>
<head>
<title>HTML 5</title>
<style>
h1 {
font-size:50px; }
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
</body>
</html>
Output:
eb Development: Next Generation Trends
Introduction:
1. Web 3.0:
2. AI and ML Integration:
9. Accessibility:
Conclusion:
Browser Support
New Features
Learning how to open an HTML file can make it easier to learn web
development skills. The following are different methods you may use to
open an HTML file:
There are different ways you can use Chrome to open your HTML files,
including:
Some steps you can follow when opening the files are:
1. Right-click on the HTML file you wish to see and select "Open
with" from the menu. You may see a long list of apps from which to
choose to open your file. Your default browser may be at the top of
the list.
2. Choose Chrome from the list, then view your file in the app.
3. If you have Chrome as your default browser, you can just double-
click the HTML file and it opens in Chrome.
4. If you try this and your computer doesn't recognize your file, the
system prompts you to open it using one of the previously installed
apps or to search the extension on the internet. Select “Open with
previously installed applications,” then select Chrome from the list
once again.
5. To ensure you've opened the right HTML file, you can check the
address bar in Chrome when you load the page. The address may
match the file location on your computer.
If your browser is already open, you can open the HTML file without
searching for it on your computer using the following steps:
1. Open the Chrome ribbon menu and select “File”, then choose “Open
File."
The drag-and-drop method can be a useful shortcut. You can follow these
steps to use it:
3. Drag your HTML file and drop it into a new tab on Chrome.
How to open the file using Notepad text editor
The following are steps you can follow to open an HTML file using the
Notepad text editor:
To open the HTML files using Microsoft Edge, follow these steps:
3. Select “Always open file with” in the dialog box that appears.
5. If Microsoft Edge isn't on the list, click on the “More apps” button and
check there.
How to open the file using Safari
If Safari is your preferred browser, you can follow this procedure to open an
HTML file:
You may follow these steps when using Firefox to open an HTML file:
1. Open Firefox.
Static or Basic Websites: Static websites are simple websites with one or
more web pages (called HTML pages). You can build them on your
computer with software like Dreamweaver and then upload the pages to
your host’s server using any FTP software (such as FileZilla).Whenever
you need to make changes to your website, you’ll have to edit the pages on
your computer and upload them again. Since they cannot be modified
dynamically, such websites are called static websites.Static websites are
cheaper than dynamic websites (below) but come with limited functionality
and no option for e-commerce or interactivity.
Linux Hosting, which allows running scripts written in PHP, Perl, Python
and other Unix-originated languages, and usually supports PostgreSQL
and MySQL databases. This is the most commonly used system today.
Windows Hosting, which allows running ASP scripts utilizing .NET and
other Microsoft technologies, and supports Microsoft SQL Server and
Access database.
Shared Hosting: In shared hosting, you get to share the physical server
with other website owners. However, you will have your own separate
account (secured with login credentials). Shared hosting is very affordable
because the cost of operating the server is shared between you and the
other website owners.
Most people start with VPS (or even shared) hosting and upgrade later as
their business grows. VPS hosting gives you professional web hosting
capabilities at a far lower price than a dedicated server.
To get your website up and working, you will need to change the Name
Servers of your domain. It’s a simple but mandatory step for you to get
started.
If you have registered your domain name with a third party provider, you
will need to log in to their Control Panel, update the Name Servers of the
domain to those provided by HostGator. However, if your domain is already
using the Name Servers of the third party provider, you can add an A
Record for the domain pointing to HostGator’s Server IP in the third Party
DNS Zone.
After you have changed your DNS, it will take about 24-48 hours for your
website to start resolving to HostGator India’s servers.
You can connect to FTP via an FTP program such as FileZilla Client. It
allows you to see the files and folders on our server like you’d see them on
your computer. You can use it to drag and drop your website’s files into the
/public_html/ folder.
To connect to your web server via FileZilla, follow these steps:
Once your FTP is connected, you will see the files and folders of your:
To upload files to your hosting service provider via FileZilla, follow these
steps:
1. From the left-hand side of FileZilla, select the file(s) and folder(s) you
want to upload.
2. Drag and drop the file(s) and folder(s) to the directory location on the
right side of your web hosting service. FileZilla will now start
uploading.
3. After the uploading is finished, FileZilla log will confirm success and
your uploads will be visible on the right-hand side.