HTML Introduction
HTML Introduction
UNIT I
Introduction to HTML5 Part - I & II.
Cascading Style Sheets (CSS) Part - I & II.
JavaScript: Introduction to Scripting, Control Statements Part - I & II.
Web technologies refers to the way computers/devices communicate with each other using
mark up languages.
It is communication across the web, and create, deliver or manage web content using
hypertext markup language (HTML).
A web page is a web document which is written in in HTML (hypertext markup language)
Introduction to HTML5 Part - I & II.
Introduction
HTML5 (Hypertext Markup Language 5)
HTML5 is a markup language that specifies the structure and content of documents that are
displayed in web browsers
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).
Editing HTML5
We’ll create HTML5 documents by typing HTML5 markup text in a text editor (such as
Notepad, TextEdit, vi, emacs) and saving it with the .html or .htm filename extension.
Computers called web servers store HTML5 documents.
Clients (such as web browsers running on your local computer or smartphone) request specific
resources such as HTML5 documents from web servers.
First HTML5 Example
Figure 2.1 is an HTML5 document named main.html.
This first example displays the message : Welcome to HTML5! in the browser.
<!DOCTYPE html>
page is displayed, and also as the text identifying a page when users add the page to their list of
Favorites or Bookmarks, enabling them to return to their favorite sites.
• Search engines use the title for indexing purposes and when displaying results
Paragraph Element
All text placed between the <p> and </p> tags forms one paragraph.
W3C HTML5 Validation Service
The World Wide Web Consortium (W3C) provides a validation service (at validator.w3.org) for checking
a document’s syntax. Documents can be validated by
• providing the URL of an online web page
• uploading a file to the validator
• pasting code directly into a text area provided on the validator site
Validation services (e.g., validator.w3.org/#validate-by-upload) ensure that an HTML5 document is
syntactically correct
Headings
HTML5 provides six heading elements (h1 through h6) for specifying the relative importance of
information
Heading element h1 is considered the most significant heading and is rendered in the largest font.
Each successive heading element (i.e., h2, h3, etc.) is rendered in a progressively smaller font.
<!DOCTYPE html>
<!-- Fig. 2.2: heading.html -->
<!-- Heading elements h1 through h6. -->
<html>
<head>
<title>Headings</title>
</head>
<body>
<h1>Level 1 Heading</h1>
<h2>Level 2 heading</h2> Heading elements h1 through h6.
<h3>Level 3 heading</h3>
<h4>Level 4 heading</h4>
<h5>Level 5 heading</h5>
<h6>Level 6 heading</h6
</body>
</html>
Linking
A hyperlink references or links to other resources, such as HTML5 documents and images.
Web browsers typically underline text hyperlinks and color them blue by default
The HTML <a> tag defines a hyperlink. It has the following syntax:
<a href="url">link text</a>
The most important attribute of the <a> element is the href attribute, which indicates the link's destination.
<!DOCTYPE html>
<html>
<body>
<h1>HTML Links Here are my favorite sites</h1>
<p><strong>Click a name to visit that site.</strong></p>
<p><a href="https://www.facebook.com/">facebook!</a></p>
<p><a href="https://www.Twitter.com/">Twitter!</a></p>
<p><a href="https://www.google.com/">google!</a></p>
<p><a href="https://www.rvrjc.ac.in/">rvrjc!</a></p>
</body>
</html>
The strong element indicates that the content has high importance. Browsers typically render such text
in a bold font.
Links are created using the a (anchor) element.
Attribute href (hypertext reference) specifies a resource’s location, such as
a web page or location within a web page
a file
an e-mail address
When a URL does not indicate a specific document on the website, the web server returns a default
web page.
This page is often called index.html, but most web servers can be configured to use any file as the
default web page for the site.
If the web server cannot locate a requested document, it returns an error indication to the web browser
(known as a 404 error), and the browser displays a web page containing an error message.
Hyperlinking to an E-Mail Address
Anchors can link to e-mail addresses using a mailto: URL. When the user clicks this type of anchored
link, most browsers launch the user’s default e-mail program (for example, Mozilla Thunderbird,
Microsoft Outlook or Apple Mail) to enable the user to write an e-mail message to the linked address.
<!DOCTYPE html>
<html>
<body>
<title>Contact Page</title>
<h2>Link to an Email Address</h2>
<p>To create a link that opens in the user's email program (to let them send a new email), use mailto:
inside the href attribute:</p>
<p><a href="mailto:[email protected]">chandu</a></p>
</body>
</html>
Images
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 is empty, it contains attributes only, and does not have a closing tag.
The <img> tag has two required attributes:
src - Specifies the path to the image
alt - Specifies an alternate text for the image
Syntax
<img src="url" alt="alternatetext">
example
<!DOCTYPE html>
<html>
<body>
<h2>Alternative text</h2>
<p>The alt attribute should reflect the image content, so users who cannot see the image get an understanding of what the image
contains:</p>
<img src="E:/Chandu/WEB Tech.rvrlogo.jpg" alt="Rvrjc college" width="100" height="45">
<img src="cse.jpg" alt="dept of cse" width="100" height="45">
<!img src="programming.gif" alt="Computer Man" style="width:48px;height:48px;"> animated images
</body>
Using Images as Hyperlinks
By using images as hyperlinks, you can create graphical web pages that link to other resources.
<!DOCTYPE html>
<html>
<title>RVRJC</title>
<body>
<p>
<a href="https://rvrjcce.ac.in/"><img src="https://rvrjcce.ac.in/rvr.jpg" alt="click me"
style="width:50px;height:50px;"></a>
</p>
</body>
</html>
Special Characters and Horizontal Rules
Characters with special meaning in HTML are called reserved characters. For example, left (<) and right (>)
angle brackets are reserved in HTML to identify the opening and closing tags of elements.
Characters that don’t appear on your keyboard include things like the copyright symbol (©) and the
mathematical value pi (π)
For example, the mark up
<p>if x < 10 then increment x by 1</p>
We could correct the previous line by writing
<p>if x < 10 then increment x by 1</p>
Horizontal Rules
In HTML <hr> tag to separate out different topics on a page.
The <hr> tag is an empty element. This means that it only has an opening tag, <hr>.
Starting in HTML5, we now need to attach a slash to the tag of an empty element. So, instead of having just
<hr>, you should make it <hr />.
The <hr /> tag accepts attributes such as width, color, size, and align.
Ex
<hr width="50” />
Most Common Character Codes
Here is a quick reference table with a few of the most commonly seen HTML character references:
Character Name Character Name in HTML Symbol
Less Than < <
Greater Than > >
Slash / /
Quotation " "
Apostrophe ' '
Ampersand & &
Copyright © ©
Registered Trademark ® ®
Degree ° °
Left-pointing double angle « «
Right-pointing double angle » »
Non-Breaking Space
Subscript: The <sub> tag is used to add a subscript text to the HTML document. The <sub> tag defines the subscript text. Subscript text
appears half a character below the normal line and is sometimes rendered in a smaller font.
Subscript text can be used for chemical formulas, like H2O to be written as H 2O.
Superscript: The <sup> tag is used to add a superscript text to the HTML document. The <sup> tag defines the superscript text.
Superscript text appears half a character above the normal line and is sometimes rendered in a smaller font. Superscript text can be used
for footnotes.
<!DOCTYPE html>
<!-- Inserting special characters. -->
<html>
<head>
<meta charset = "utf-8">
<title>Contact Page</title>
</head>
<body>
<p>
<a href = "mailto:[email protected]">Send an email to rvrjc & colleges, Inc.</a>.
</p>
<hr> <!-- inserts a horizontal rule -->
<!-- special characters are entered -->
<!-- using the form &code; -->
<p>All information on this site is <strong>© rvrjc college, Inc. 1985.</strong> </p>
<!-- to strike through text use <del> element -->
<!-- to subscript text use <sub> element -->
<!-- to superscript text use <sup> element -->
<!-- these elements are nested inside other elements -->
<p><del>You may download 3.14 x 10<sup>2</sup>
characters worth of information from this site.</del>
The first item in the series is x<sub>1</sub>.</p>
<p>Note: < ¼ of the information presented here is updated daily.</p>
</body>
Lists <!DOCTYPE html>
• HTML offers three ways for specifying lists of information. All <html>
lists must contain one or more list elements. Lists may contain − <head>
<ul> − An unordered list. This will list items using plain bullets. <title>HTML Unordered List</title>
</head>
<ol> − An ordered list. This will use different schemes of
numbers to list your items. <body>
<ul>
<dl> − A definition list. This arranges your items in the same way
as they are arranged in a dictionary. <!ul type = "disc">
<li>Beetroot</li>
HTML Unordered Lists
<li>Ginger</li>
• An unordered list is a collection of related items that have no
<li>Potato</li>
special order or sequence.
<li>Radish</li>
• This list is created by using HTML <ul> tag. Each item in the
</ul>
list is marked with a bullet.
</body>
The type Attribute
</html>
You can use type attribute for <ul> tag to specify the type of bullet you like. By
default, it is a disc. Following are the possible options − O/P
<ul type = "square"> • Beetroot
<ul type = "disc"> • Ginger
<ul type = "circle"> • Potato
• Radish
HTML Ordered Lists <!DOCTYPE html>
• If you are required to put your items in a numbered list instead of bulleted, then HTML <html>
ordered list will be used. <head>
• This list is created by using <ol> tag. The numbering starts at one and is incremented <title>HTML Ordered
by one for each successive ordered list element tagged with <li>. List</title>
The type Attribute </head>
We can use type attribute for <ol> tag to specify the type of numbering you like. By <body>
default, it is a number.
<ol>
Following are the possible options −
<!ol type = "1">
• <ol type = "1"> - Default-Case Numerals.
• <ol type = "I"> - Upper-Case Numerals.
<li>Beetroot</li>
• <ol type = "i"> - Lower-Case Numerals. <li>Ginger</li>
• <ol type = "A"> - Upper-Case Letters. <li>Potato</li>
• <ol type = "a"> - Lower-Case Letters <li>Radish</li>
The start Attribute </ol>
We can use start attribute for <ol> tag to specify the starting point of numbering you </body>
need. Following are the possible options −
</html>
• <ol type = "1" start = "4"> - Numerals starts with 4.
• <ol type = "I" start = "4"> - Numerals starts with IV. 1.Beetroot
• <ol type = "i" start = "4"> - Numerals starts with iv. 2.Ginger
• <ol type = "a" start = "4"> - Letters starts with d. 3.Potato
HTML Definition Lists <!DOCTYPE html>
• HTML5 supports a list style which is called definition <html>
lists where entries are listed like in a dictionary or <head>
encyclopedia. The definition list is the ideal way to
present a glossary, list of terms, or other name/value <title>HTML Definition List</title>
list. </head>
Definition List makes use of following three tags. <body>
• <dl> − Defines the start of the Definition list <dl>
• <dt> − Definition term <dt><b>HTML</b></dt>
• <dd> − definition Data <dd>This stands for Hyper Text
</dl> − Defines the end of the Definition list Markup Language</dd>
Output: <dt><b>HTTP</b></dt>
HTML <dd>This stands for Hyper Text
Transfer Protocol</dd>
This stands for Hyper Text Markup Language
</dl>
HTTP
</body>
This stands for Hyper Text Transfer Protocol
</html>
<!DOCTYPE html> <li>New applications
<!-- Nested lists and ordered lists. --> <!-- nested ordered list -->
<html> <ol>
<title>Lists</title> </ol>
</body>
Tables
Tables are frequently used to organize data into rows and columns
<caption> : Defines the title of a <table>.
<table> : Defines a container for tabular data, the entire table is represented by the HTML5 table tag. This tag looks like this <table>. The
<table> tag is a container tag – its purpose is to hold the other components of the tag. The <table> tag has a mandatory closing tag
</table>.
<thead> : Defines a group of table rows <tr> at the start of a <table>.
thead – is the head of the table. This area usually contains the column headings
<tr> : Defines a table row, a single row is represented by the <tr> tag.
<tbody> : Defines a group of table rows <tr>.like is the body of the table. The table data.
<td> : Defines a table cell. Must be a direct child of a <tr>.
<th> : Defines a table header, Must be a direct child of a <tr>.
a single cell is represented by either a <td> or <th> tag.
A <td> tag (the “td” stands for “table data”) is used for inserting data into the table.
A <th> tag (the “th” stands for “table header”) is used for inserting headings into the table.
<tfoot> : Defines a group of table rows <tr> at the end of a <table>.
The tfoot section is defined with a tfoot (table foot) element. The text placed in the footer commonly includes calculation results and
<!DOCTYPE html> <th>$3.75</th>
<!-- Creating a basic table. --> </tr>
<html> </tfoot>
<head> <!-- all table content is enclosed -->
<meta charset = "utf-8"> <!-- within the <tbody> -->
<title>A simple HTML5 table</title> <tbody>
</head> <tr>
<body> <td>Apple</td> <!-- insert a data cell -->
<!-- the <table> tag opens a table -->
<td>$0.25</td>
<table border = "1">
</tr
<!-- the <caption> tag summarizes the table's -->
<tr>
<!-- contents (this helps visually impaired people) -->
<td>Orange</td>
<caption><strong>Table of Fruits (1st column) and
<td>$0.50</td>
Their Prices (2nd column)</strong></caption>
<!-- the <thead> section appears first in the table --> </tr>
<thead> <td>Banana</td>
<tr> <tr>
<td colspan="3"> <td> February </td>
Temperature Distribution In Jan – Apr 2015 <td> 49 </td>
</td> <td> 37 </td>
</tr> <td rowspan="2"> 43 </td>
<tr> <tr>
<td> month </td> <td> march </td>
<td> high </td> <td> 49 </td>
<td> low </td> <td> 37 </td>
<td > avg</td>
</tr> </tr>
</tr>
</table> </body> </html>
</th>
<!DOCTYPE html>
</tr>
<!-- Complex HTML5 table. -->
<tr>
<html>
<th># of humps</th>
<head>
<th>Indigenous region</th>
<meta charset = "utf-8">
<th>Spits?</th>
<title>Tables</title>
<th>Produces wool?</th>
</head> </tr>
<body> </thead>
<h1>Table Example: Spanning Rows and Columns</h1> <tbody>
<table border = "1"> <tr>
<thead> <td>2</td>
<tr> <td>Yes</td>
</tr>
<!-- merge two rows -->
<tr>
<th rowspan = "2">
<th>Llamas</th>
<img src = "camel.jpg" width = "205"
<td>1</td>
height = "167" alt = "Picture of a camel">
<td>Andes Mountains</td>
</th>
<td>Yes</td>
<!-- merge four columns -->
<td>Yes</td>
<th colspan = "4">
</tr>
<strong>Camelid comparison</strong><br>
</tbody> </table> </body> </html>
Approximate as of 10/2023
Forms
<p><label>Name:
• A form is a section of a document which contains controls such as
<input name = "name" type = "text" size = "25" maxlength = "30">
text fields, password fields, checkboxes, radio buttons, submit
button, menus etc. </label></p
• A form facilitates the user to enter data that is to be sent to the <p>
server for processing such as name, email address, password, <!-- input types "submit" and "reset" insert -->
phone number, etc. . <!-- buttons for submitting and clearing the -->
<!DOCTYPE html>
<!-- form's contents, respectively -->
<!-- Form with a text field and hidden fields. -->
<html> <input type = "submit" value = "Submit">
<head> <input type = "reset" value = "Clear">
<meta charset = "utf-8">
</p>
<title>Forms</title>
</form>
</head>
<body> </body>
<h1>Feedback Form</h1> </html>
<p>Please fill out this form to help us improve our site.</p>
<!-- this tag starts the the form, gives the -->
<!-- method of sending information and the -->
<!-- location of the form-processing script -->
<form method = "post" action = "http://www.rvrjcce.ac.in">
<!-- hidden inputs contain non-visual -->
<!-- information that will also be submitted -->
<input type = "hidden" name = "recipient"
<!DOCTYPE html>
<label>Enter your phone🤳 number:<br/><small>format:123-456-7890</small></label>
<!-- Form with a text field and hidden fields. -->
<html>
<input type = "tel" id = "phone" name = "phone" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required/>
<head>
<meta charset = "utf-8">
<title>Forms</title> </p>
</head> <p><input type = "radio" name = "Gender" value = "Male"> Male
<body> <input type = "radio" name = "Gender" value = "Female"> Female</p>
<h1>Feedback Form</h1> <p><input type = "checkbox" name = "hi"value = "Sports" > </p>
<p>Please fill out this form to help us improve our site.</p>
<!-- this tag starts the the form, gives the --> <label for="Programming">PROGRAMMING</label>
<!-- method of sending information and the --> <select id="pogramming" name="PROGRAMMING">
<!-- location of the form-processing script --> <option value="C">C</option>
<form method = "post" action = "http://www.rvrjcce.ac.in"> <option value="PYTHON">PYTHONL</option>
<!-- hidden inputs contain non-visual --> <option value="OOP">OOP</option>
<!-- information that will also be submitted --> <option value="PHP">PHP</option>
<input type = "hidden" name = "recipient" <option value="HTML">HTML</option>
value = "[email protected]"> <option value="CSS">CSS</option>
<input type = "hidden" name = "subject" <option value="JavaScript">JavaScript</option>
value = "Feedback Form"> </select>
<!-- <input type = "text"> inserts a text field --> <p>
<p><label>Name: <!-- input types "submit" and "reset" insert -->
<input name = "name" type = "text" size = "25" maxlength = "30">
<!-- buttons for submitting and clearing the -->
</label></p>
<!-- form's contents, respectively -->
<p><label>Branch:
<input type = "submit" value = "Submit">
<input name = "Branch" type = "text" size = "25" maxlength = "30">
<input type = "reset" value = "Clear">
</label></p>
</p>
<p><label>Branch:
</form>
<input name = "Address" type = "text" size = "25" maxlength = "300">
</body>
</label></p>
</html>
Internal Linking
internal linking—a mechanism that enables the user to jump between locations in the same document.
Internal linking is useful for long documents that contain many sections. Clicking an internal link enables the user to find a section without
scrolling through the entire document.
The <em> tag is used to define emphasized text. The content inside is typically displayed in italic.
<!DOCTYPE html>
<!-- Internal Linking -->
<html>
<head>
<meta charset = "utf-8">
<title>Internal Links</title>
</head>
<body>
<!-- id attribute creates an internal hyperlink destination -->
<h1 id = "features">The Best Features of the Internet</h1>
<!-- an internal link's address is "#id" -->
<p><a href = "#bugs">Go to <em>Favorite Bugs</em></a></p>
<ul>
<li>You can meet people from countries around the world.</li>
<li>You have access to new media as it becomes public:
<ul>
<li>New games</li> <!-- id attribute creates an internal hyperlink destination -->