FSD Module1 HTML
FSD Module1 HTML
FSD Module1 HTML
2
HTML
3
VERSIONS OF HTML
4
VERSIONS OF HTML
• HTML 1.0 : Supports only basic tags. Do not support tables, font changes etc.
• XHTML: HTML with XML elements. Follows very strict way of coding.
6
HTML STRUCTURE
7
HTML STRUCTURE
8
Cont.…
• <!DOCTYPE html>, specifies the type of the document. In this case, the
type of file is html.
• <html lang =‘en-us’> html tag includes attribute lang, specifies the language
in which the document is written.[specifies the language code of the page followed by the country code
that means US style of English language is used for all the text on the page.]
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>lang Attribute</title>
<style>
body{
text-align: center;
}
h1{
color: green;
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<p>jQuery is an open source JavaScript library that
simplifies the interactions between an HTML/CSS document,
or more precisely the Document Object Model (DOM), and JavaScript.
Elaborating the terms, jQuery simplifies HTML document
traversing and manipulation, browser event handling,
DOM animations, Ajax interactions, and cross-browser
JavaScript development.</p>
</body>
ELEMENTS & TAGS
• HTML uses predefined tags and elements, that tells the browser how to
display the content.
• For every opening tag there should be a closing tag </> (with forward slash).
• A HTML document can be saved using .html or .htm extension and can be
opened in the browser.
12
COMMENTS IN HTML
• Comments increase the readability of the programs.
• Browsers ignore the comments. The comments are only for the users.
a Multi-line
comment --> 13
HEADING
▪ HTML heading tags are defined from <h1> to <h6>.
▪ <h1> defines most important heading.
▪ <h6> defines the least important heading.
▪ Ex: < h1> This is H1 heading </h1>
< h2> This is H2 heading </h2>
< h3> This is H3 heading </h3>
< h4> This is H4 heading </h4>
< h5> This is H5 heading </h5>
<h6>jfdnfj</h6>
14
PARAGRAPH
▪ Text is often organized in paragraph.
▪ It is represented with <p>.
▪ Line break embedded in text are ignored by the
browser.
▪ Ex: <p> This is a paragraph tag </p>
15
<PRE> & <BR>
▪ If the whitespaces or new line characters need to be
preserved, <pre> tag is used.
▪ Ex: <pre> Mary had
A little lamb </pre>
▪ To insert line breaks or paragraph breaks, <br> tag is used.
▪ <p> This is a <br> Paragraph </p>
U will get This is a
Paragraph
16
Formatting
Use pre to retain format of text and display using monospace font:
Note that any embedded markup (such as <br /> ) is still treated as
markup!
17
Output:
18
Different HTML Attributes(for your knowledge)
Core Attributes
id, The title Attribute, class Attribute, The style Attribute Internationalization
Attribute Lang Attribute used in HTML Tag
Generic Attribute
align Attribute, src attribute, alt attribute ,width and height attribute, href
attribute.
19
Cont.…
Data Attribute
HTML also provides custom data attributes that help you to add information
related to you in HTML tags. These are not specific to HTML5 and can be used
on all HTML elements. The data -* attribute helps us in customizing our own
custom data attributes; it can store the data privately to the page or the
application.
20
For knowledge :Core HTML attributes
Block-level Elements
A block-level element always takes up the full width available (stretches out to
the left and right as far as it can).
A block level element has a top and a bottom margin, whereas an inline element
does not.
21
Cont..
22
Example on div(will repeat in css)
<!DOCTYPE html>
<html>
<body>
<p>The DIV element is a block element, and will always start on a new line and take
up the full width available (stretches out to the left and right as far as it can).</p>
</body>
</html>
23
formatting cont…(<span>comes in CSS portions:inline)
HTML <span> tag
HTML <span> tag is used as a generic container of inline elements. It is used for styling
purpose to the grouped inline elements (using class and id attribute or inline style).
The <span> tag does not have any default meaning or rendering.
The <span> tag can be useful for the following task:
The HTML <span> tag is used for grouping and applying styles to inline elements.
There is a difference between the span tag and the div tag. The span tag is used with inline elements
whilst the div tag is used with block-level content.
24
25
Output
26
Another Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</html>
27
Fonts
The CSS font-family property defines the font to be used for an HTML
element:
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
output
28
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
29
output:
30
Summary for HTML style
31
<h1 style="text-align:center;">Centered Heading</h1>
• Important text<strong>: Element defines text with strong importance. The content inside is
typically displayed in bold.
• Italic text <i>: The content is displayed in italic. It is often used to indicate a technical term.
• Emphasized text <em>: The element defines emphasized text. It is used for emphasis or
emphasizing.
• Marked text <mark>: The element defines text that should be marked or highlighted.
• Inserted text <ins>: The element defines a text that has been inserted into a
document. Browsers usually underline inserted text.
• Superscript text <sup>: The element defines superscript text. It appears half a
character above the normal line. And is rendered in a smaller font.
• Subscript text <sub>: The element defines subscript text. It appears half a
character below the normal line.
34
Cont..
<code>
The code element, code, is used to specify a monospace font, usually for program
code. For example, consider the following element:
<code> cost = quantity * price </code>
This markup would be displayed as shown
35
Cont..
36
CHARACTER ENTITIES *note= &
37
https://www.geeksforgeeks.org/container-and-empty-tags-in-html/
EMPTY TAGS
39
40
HORIZONTAL RULES
• Two parts of a document can be separated from each other by placing a horizontal
line between them.
• These lines are called horizontal rules.
• <hr /> is used to create a line.
• The thickness, length and horizontal placement will be chosen by the browser.
• Two parts of a document can be separated from each other by placing a horizontal
line between them.
• These lines are called horizontal rules.
• <hr /> is used to create a line.
• The thickness, length and horizontal placement will be chosen by the browser.
41
IMAGE TAG
• <img>: The image tag is used to include an image in an HTML page. They are not inserted;
but linked to a webpage.
• <img> tag creates a holding space for the referenced image.
• Width and height of an images should be specified.
• The <img> tag has 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.
• height
• width
• float
42
IMAGE TAG
43
LISTS
▪ Lists are nothing but a group of elements. There are three types of Lists:
▪ Unordered list or Bulleted list (ul)
▪
Ordered list or Numbered list (ol)
▪ Description list or Definition list (dl)
element. The only allowed value for this attribute is a number, even if the list is displayed
with Roman numerals or letters.
45
type
-*Deprecated
Non-standard
This character attribute indicates the numbering type:
● a: lowercase letters
● A: uppercase letters
● i: lowercase Roman numerals
● I: uppercase Roman numerals
● 1: numbers
This type overrides the one used by its parent <ol> element, if any.
Note: This attribute has been deprecated; use the CSS list-style-type property instead.
<ol type="I">
<li value="3">third item</li>
<li>fourth item</li>
<li>fifth item</li>
</ol>
ORDERED LIST
• An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. The list items
will be marked with numbers by default:
• Ex 1: Ordered List
• <ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
47
ORDERED LIST
48
UNORDERED LIST
• An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. The list items
will be marked with bullets (small black circles) by default:
• <ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
49
UNORDERED LIST
50
DESCRIPTION LIST
• A description list is a list of terms, with a description of each term. The <dl> tag
defines the description list, the <dt> tag defines the term (name), and the <dd> tag
describes each term:
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
51
DESCRIPTION LIST
52
HYPERLINKS
53
lists(type attribute and value attribute)
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li
value
This integer attribute indicates the current ordinal value of the list item as defined by the <ol> element. The only allowed value for this attribute is
a number, even if the list is displayed with Roman numerals or letters. List items that follow this one continue numbering from the value set. The
value attribute has no meaning for unordered lists (<ul>) or for menus (<menu>).
type
Deprecated
Non-standard
This character attribute indicates the numbering type:
● a: lowercase letters
● A: uppercase letters
● i: lowercase Roman numerals
● I: uppercase Roman numerals
● 1: numbers
This type overrides the one used by its parent <ol> element, if any.
DESIGN THE FOLLOWING NESTED LIST
55
<!DOCTYPE html>
<li> Commercial aviation</li>
<html> <ol>
<body> <li> Dual engine</li>
<ol> <ol>
<li> General Aviation </li> <li>Wing- mounted... </li>
<ol> <li> Fuesalage mounted... </li>
<li> single engine</li>
<ol> </ol>
<li>Tail Wheel </li>
<li> Tricycle </li> <li> Tri engine </li>
</ol> <ol>
<li>Third engine in Vertical.. </li>
<li> dual engine </li> <li> Third engine in fuselage </li>
<ol>
<li>Wing Mounted </li> </ol>
<li> Push-pull.... </li>
</ol> </ol>
</ol>
</ol> </body>
</html>
<html>
<head>
<style type = "text/css">
ol {list-style-type: upper-roman;}
ol ol {list-style-type: upper-alpha;}
ol ol ol {list-style-type: decimal;}
</style></head>
<body>
<ol> <!-- OR <ol type= I>- ->
<li> General Aviation </li>
<ol> <!-- OR <ol type= A>- ->
</ol>
57
</ol>
</ol>
</ol>
</ol>
</ol>
</body>
</html>
58
59
Nested List
<!DOCTYPE html> <ul>
<html>
<li>HTML</li>
<li>CSS</li>
<body>
<h1 style="color:green">GeeksforGeeks</h1>
<li>JavaScript</li>
<h2>Nested Unordered List</h2> </ul>
<p>GeeksforGeeks courses list:</p> <li>Aptitude</li>
<li>Gate</li>
<ul>
<li>Placement</li>
<li>DSA</li>
</ul>
<ul>
<li>Array</li>
</body>
<li>Linked List</li> </html>
<li>stack</li>
<li>Queue</li>
</ul>
<li>Web Technologies</li>
60
61
Anchor tag example
62
63
64
Cont…
Links can include images in their content, in which case the browser displays
the image together with the textual link:
65
IMAGE TAG WITH PROPERTIES
66
Cont…
<!DOCTYPE html>
<html>
<body>
</body>
</html>
67
68
Float property of image
<html>
<head>
<title>HTML Floating Image</title>
</head>
<body>
<h1>Float Right</h1>
<p>The below image floats to the right.</p>
<p>
<img src="https://www.tutorialspoint.com/green/images/logo.png" style="float:right" width="190" height="84" />
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
69
</p>
Cont…
<h1>Float Left</h1>
<p>The below image floats to the left.</p>
<p>
<img src="https://www.tutorialspoint.com/green/images/logo.png" style="float:left" width="190"
height="84" />
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
This is demo text. This is demo text.
</p>
</body>
</html> 70
71
ANCHORS
72
Targets within Documents
Consider the following example
<h2 id = "avionics"> Avionics </h2>
If the target is in the same document as the link, the target is specified in the href attribute value by
preceding the id value with a pound sign (#), as in the following example:
<a href = "#avionics"> What about avionics? </a>
When the What about avionics?link is taken, the browser moves the display so that the element
whose id is avionics is at the top.
When the target is an element in another document, the value of that ele- ment’s id is specified at the
end of the URL, separated by a pound sign (#), as in the following example:
<a href = "aidan1.html#avionics"> Avionics </a>
Viva type: How to Open Hyperlinks in a New Browser Tab or Window
answer is: just add a target="_blank" attribute to your links (anchor tags).
73
target=_blank (to open in new tab)
Tables
75
TABLES
• Tables allows the users to arrange the data in rows and columns. Each tag has a
start and end tag
• For tables, <table> tag is used.
• eg <table border=5 bgcolor = "yellow" width=100%>
• Each table row is defined with a <tr> tag.
• Each table header is defined with a <th> tag.
• Each table data/cell is defined with a <td> tag.
• By default, the text in <th> elements are bold and centered.
• By default, the text in <td> elements are regular and left-aligned.
76
TABLES
77
COLSPAN AND ROWSPAN
78
79
HTML FORMS
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 80
HTML FORMS
81
LABEL TAG
▪ The <label> element is useful for the users to identify the input.
▪ The for attribute of the <label> tag should be equal to id attribute of the
<input> tag to bind them together.
82
TEXT FIELD
▪ The <input type =“text” defines a single-line input field for text input.
▪ Ex: <form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value = “”>
▪ </form>
83
RADIO BUTTON
• The <input type =“radio” > defines a radio button. Radio button lets a user
to select only one of the choices.
• Ex: : <form>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label><br>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label><br>
</form>
84
CHECK BOXES
• The <input type =“checkbox”> defines a check.box.
• User can select zero or more options out of the choices.
• Ex: form>
• The <input type = “submit”> defines a button for submitting the data to a form
handler.
• The form-handler is typically a file on the server with a script for processing input
data.
• Ex: <form>
</form>
86
EXAMPLES/TUTORIALS
87
Example (input type=password)
88
89
Example of text area, select, email, range, reset -->
90
select—-- Text Area
>(Menu>
<select id="cars" name="cars"> <textarea id="w3review"
<option value="volvo">Volvo</option> name="w3review" rows="4"
<option value="saab">Saab</option> cols="50">
<option value="fiat">Fiat</option> you will learn how to make a
<option value="audi">Audi</option> website. They offer free
tutorials in all web
</select> development technologies.
</textarea>
91
Input type=email/url/range/submit/reset
<input type="email" id="email" name="email">
<input type = "range" id = "myAge" name = "myAge" min = "18" max = "110" >
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 93
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 94
Use of Field set and legend
Definition and Usage
Tip: The <legend> tag is used to define a caption for the <fieldset> element.
Global Attributes
The <fieldset> tag also supports the Global Attributes in HTML.
Event Attributes
The <fieldset> tag also supports the Event Attributes in HTML.
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 95
<!DOCTYPE html> <body>
<html>
<head> <h1>The fieldset element + CSS</h1>
<style>
fieldset { <form action="/action_page.php">
background-color: #eeeeee; <fieldset>
} <legend>Personalia:</legend>
<label for="fname">First name:</label>
legend { <input type="text" id="fname"
background-color: gray; name="fname"><br><br>
color: white; <label for="lname">Last name:</label>
padding: 5px 10px; <input type="text" id="lname"
} name="lname"><br><br>
<label for="email">Email:</label>
input { <input type="email" id="email"
margin: 5px; name="email"><br><br>
} <label for="birthday">Birthday:</label>
</style> <input type="date" id="birthday"
</head> name="birthday"><br><br>
<input type="submit" value="Submit">
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 96
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 97
<html> <legend> Card information</legend>
<body> <TABLE BORDER="1">
<form action=“” method=“GET> <TR> <td> credit card</td>
<fieldset>
<TD><select id="cards" name="card" >
<legend>Personal information</legend>
<TABLE BORDER="1">
<option value="default" selected>SELECT A CREDIT
<TR> CARD</option>
<TD>Your name</TD> <option value="MASTER CARD”>master card/option>
<TD> <option value="VIVA">viva</option>
<INPUT TYPE="TEXT" NAME="name" SIZE="50">
</select> </TD </TR>
</TD> </TR>
<TR>
<tr> <td> Account number</td>
<TD>Your email</TD> <TD> <td> <input type=text name=account size="25"> </td>
<INPUT TYPE="EMAIL" NAME="name" SIZE="50"> <tr> <td>date</td> <td><input type=date name=date
</TD> size="25"> </tr></TABLE> </fieldset> </table>
</TR> <TR> <TD>address</TD>
<span> “please keep me informed of further ordering”
<TD> <textarea id="w3review" name="w3review"
rows="4" cols="50">
</span> <input type=”checkbox” checked><input type=submit
</textarea> value=Submit><input type=reser value=”clear”>
</TD> </TR></TABLE> </fieldset>
</table>
<fieldset>
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 98
Output
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 99
HTML MEDIA TAGS : The audio Element :
The only commonly used attribute of the audio element is controls, which we always set
to "controls". This attribute, when present, creates a display of a start/stop button, a
clock, a slider of the progress of the play, the total time of the file, and a slider for
volume control.
*Audio information is coded into digital streams with encoding algorithms called audio
codecs. There are a large number of different audio codecs. Among these the most
commonly used on the Web are MPEG-3 (MP3), Vorbis, and Wav.
Coded audio data is packaged in containers. A container can be thought of as a zip file;
it<audio
is a way to pack data into a file, but the encoding of the data in the file is irrelevant to
attributes>
<source src = "filename1"> Note:There are three different
the container. A zip
<source src = "filenamen">
file may contain textual data coded in ASCII or it might contain
audio container types: Ogg,
floating-point
Your browser doesnumbers
not supportcoded in element
the audio binary. Likewise, an audio container may contain MP3
MP3, and Wav.
</audio>
or Vorbis coded audio.
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 100
HTML MEDIA TAGS: Audio tag and video tag
<!DOCTYPE html> <!–– audio.html This is a test of the audio element <audio
controls = "controls" >
test the audio element --> <source src = "nineoneone.ogg" />
<html lang = "en"> <source src = "nineoneone.wav" />
<head> <source src = "nineoneone.mp3" />
<title> test audio element </title> <meta charset Your browser does not support the audio
= "utf-8" /> element
</head> </audio>
<body> </body>
</html>
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 101
The Video Element
Video information, like audio information, must be digitized into data files before it can be played by
a browser, this time by algorithms called video codecs. As is the case with audio, video data is stored
in containers.
There are many different video containers and many different video codecs. Further complicating the
situation is the fact that not all video codecs can be stored in all video containers.
The most com- mon video containers used on the Web are MPEG-4 (.mp4 files), Flash Video (.flv
files), Ogg (.ogv files), WebM (.webm files), and Audio Video Interleave (.avi files).
The most common video codecs used on the Web are H.264 (also known as MPEG-4 Advance
Video Coding, or MPEG-4 AVC), which can be embedded in MP4 containers, Theora, which can be
embedded in any container, and VP8, which can be embedded in WebM containers.
In addition to video data, video containers also store audio data, because most video is
accompanied by audio. The three most common container/video codec/audio codec combinations
used on the Web are the Ogg container with Theora video codec and Vorbis audio codec, MPEG-4
container with H.264 video codec and AAC audio codec, and WebM container with VP8 video codec
and Vorbis audio codec.
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 102
HTML: MEDIA TAGS- VIDEO
This is a test of the video element.....
<!DOCTYPE html> <!–– testvideo.html
<video width = "600" height = "500" autoplay =
test the video element
"autoplay"
––>
controls = "controls" preload = "preload">
<html lang = "en">
<source src = "NorskTippingKebab.mp4" />
<head>
<source src = "NorskTippingKebab.ogv" />
<meta charset = "utf-8" />
<source src = "NorskTippingKebab.webm" />
<title> test video element </title>
Your browser does not support the video
</head>
element
<body>
</video>
</body>
</html>
Full Stack Development & 20CS2406 Department of Computer Science & Engineering 103
https://stackoverflow.com/questions/7055393/center-image-using-
text-align-center#:~:text=In%20response%20to%20your
%20question,containing%20span%20(or%20div%20).&text=A%20span
%20element%20is%20display,center%3B%20on%20the%20img
%20itself.
https://www.geeksforgeeks.org/container-and-empty-tags-in-html/