HTML
HTML
M Vishnuvardhan,
Dept. of Computer Science,
SSBN Degree College, ATP
Content
s
» Images
» L in k s
» HTML Lists
» Tables
» Forms
» Video/Audio
M V nuvardhan
Introduction
» Internet: The Internet is a global wide area network
that
connects computer systems across the world.
www.
M V nuvardhan
HTML - Introduction
» HTML stands for Hyper Text Markup Language
content.
M V nuvardhan
HTML Element
» An HTML element is defined by a start tag, some content, and an
end tag:
<tagname>Content goes here...</tagname>
» The HTML element is everything from the start tag to the end tag:
Eg: <h1>My First Heading</h1>
<p>My first paragraph.</p>
M V nuvardhan
HTML Sectioning Elements
» HTML 5 introduced number of sectioning elements which have
more semantic meaning used to mark up pages :
M V nuvardhan
HTML Sectioning Elements
<header> : represents a container for introductory content You can
have several <header> elements in one HTML document. However,
<header> cannot be placed within a <footer>, <address> or
another <header> element.
<nav> : defines a set of navigation links.
<section> : defines a section in a document. A web page could
normally be split into sections for introduction, content, and contact
information.
<article> : specifies independent, self-contained content.
M V nuvardhan
HTML Generic Containers
HTML two non semantic elements can be used as generic containers
M V nuvardhan
HTML Elements
<p> <cite>
<address> <q> <code>
<figure> <blockquote> <pre>
<figcaption> <mark> <small>
<time> <abbr> <br>
<strong> <sup> <wbr>
<em> <sub> <meter>
<b> <ins> <progress>
<i> <del>
<u> <s>
M V nuvardhan
ARIA
WAI-ARIA (Web Accessibility Initiative’s Accessible Rich Internet
Applications), or ARIA for short fills semantic gaps with attributes.
Syntax:
<element role=“value”>
Values can be
It’s generally a good idea to add ARIA landmark roles to our HTML.
M V nuvardhan
Naming HTML Elements
HTML elements can be named using ID or class attribute.
HTML id attribute is used to specify a unique id for an HTML
element. You cannot have more than one element with the same id
in an HTML document.
M V nuvardhan
CSS - Introduction
» CSS stands for Cascading Style Sheets
M V nuvardhan
CSS
Syntax
A CSS rule-set consists of a selector and a declaration block:
M V nuvardhan
Apply CSS to elements
CSS for the elements can be specified in the style tag. Style tag should
be placed in head tag.
Syntax:
<style> Eg:
element <style>
h1
{ {
property: color: orange;
}
value; </style>
}
</style>
M V nuvardhan
Formatting Text with Styles
CSS can be used to change font, size, line height, foreground,
background colors, spacing and alignment of the text. These changes
can be done for part or entire web page.
font-family:
Choosing right font is essential. Since browsers support few fonts it is
necessary to choose alternate fonts also.
Syntax: font-family: “font1",
“font2”, … ,fontn;
Eg:
H1 {
font-family: "Times New Roman",
“Times”, “serif”;
}
M V nuvardhan
Formatting Text with Styles
font-style:
Syntax: font-style:stylename;
Where style can be normal, italic or oblique
Eg:
H1 { font-style: italic; }
M V nuvardhan
Formatting Text with Styles
font: setting all properties at once. This is inherited property
Syntax: font: font-style font-weight
normal/smallcaps font-size/ line-height
font-family;
Here order is important and size and family-name are mandatory.
Eg:
p { font: 13px/2 “times”; }
p { font: italic bold smallcaps 13px/2 “times”; }
M V nuvardhan
Setting Colors
Colors can be specified with color names or hexa-decimal or rgb values
or rgb percetages or hsl values.
Syntax:
color: color-name;
color: #rrggbb; (Hexadecimals -00 to FF)
color: rgb(r,g,b); (r,g,b values can be 0- 255)
color: hsl(h,s,l);
(h can be 0-360 and s, l cab be 0-100%)
Eg:
P{color: red; }
P{color: #FF3344; }
P{color: rgb(15,65,71);
}
P{color: hsl(5,75%,65%); MV
} nuvardhan
Setting Colors
Colors can be specified with transparency.
color: rgb(r,g,b, a); (a – 0.0 to 1.0)
color: hsl(h,s,l, a);
Where a is alpha transparency 0- transparent and 1 – opaque
Eg:
P{color: rgb(15,65,71,0.7); }
P{color: hsl(5,75%,65%,0.9); }
M V nuvardhan
Text background
It possible to set background of individual elements or whole page.
Background can be color or image.
Syntax: background:color;
background:url(image-path);
Where image should be specified with full path along with extension.
Eg:
p {background: ”red”; }
p {background : url(“sample.jpg”);}
M V nuvardhan
Spacing – words or letters
Word spacing is between words and letter spacing is spacing between
letters. These are inherited.
Syntax: word-spacing :length;
letter-spacing :length;
Where length can be in pixels or em. It can be negative also.
Eg:
p {word-spacing:5px ; }
M V nuvardhan
indents
Text-indent property determines how much space precede the first
line of the paragraph. It is inherited property.
Syntax: text-indent :length;
Where length can be in pixels or em. Negative value creates hanging
indent .
Eg:
p {text-indent: 40px; }
p {text-indent: 2em; }
p {text-indent: -15px; }
M V nuvardhan
Alignments and
transformations text-align: used
to set the alignment of the text Syntax: text-align
:value;
Where value can be left, center, right or
justify.
Eg:
p {text-align
:center;}
text-transform: used to set text
case
Syntax: text-transform
:value;
Where value can be capitalize, uppercase, lowercase.
Eg:
p {text-transform
:uppercase;}
M V nuvardhan
Fontvariants and Text
decorations Font-variant: used to set the
font normal or small caps Syntax: font-variant
:value;
Where value can normal or small caps.
Eg:
p {font-variant :smallcaps;}
text-decoration: used to decorate the text.
Syntax: text-decoration :value;
Where value can be over-line, under-line, line-through or combination.
Eg:
p {text-decoration : under-line;}
p {text-decoration : under-lineover-
line;}
M V nuvardhan
Images in Webpage
Images can improve the design and the appearance of a web page.
Web pages support many formats but most common formats
are jpeg/jpg , gif and png.
Various factors to distinguish images:
» Format
» Color
» Size and Resolution
» Speed
» Transparency
» Animation
M V nuvardhan
HTML <img>
The HTML <img> tag is used to embed an image in a web
page. <img> tag has two required attributes:
Syntax:<img src="url"
alt="alternatetext"> Eg:
M V nuvardhan
Image location– File path
A file path describes the location of a file in a web site's folder
structure.
Absolute Paths:
An absolute file path is the full URL to a file:
Eg:<img
src="https://www.ssbnc.in/images/pic.jpg">
Relative File Paths
A relative file path points to a file relative to the current page.
Path Description
<img src="picture.jpg"> The "picture.jpg" file is located in the same folder
as the current page
<img src="images/picture.jpg"> The "picture.jpg" file is located
in the images folder in the
current folder
<img src="../picture.jpg"> The "picture.jpg" file is located in the folder one level
up
from the current folder
M V nuvardhan
Image dimensions
HTML image dimensions can be specified in two ways
<img src=“html.jpg"style="width:500px;height:600px;">
M V nuvardhan
Links - Introduction
HTML links are hyperlinks. You can click on a link and jump
to another document. The HTML <a> tag defines a hyperlink.
Hyper link consists of two parts label and destination
Syntax:
M V nuvardhan
Links – Anchorsor Bookmarks
Bookmarks can be useful to navigate in a page. To create a
bookmark - first create the bookmark, then add a link to it.
When the link is clicked, the page will scroll down or up to the
location with the bookmark
» Linking bookmark
1. Ordered Lists
2. Un ordered Lists
3. Description Lists
M V nuvardhan
Ordered Lists
An ordered list starts with the <ol> tag. Each list item
starts
with the <li> tag.
default: E.g.:
<ol> li>
<li>Red</ </ol>
li>
<li>Green</
li>
<li>Blue</
Output 2. Green
1. Red 3. Blue
M V nuvardhan
Un ordered Lists
An unordered list starts with the <ul> tag. Each list item
starts
with the <li> tag.
Syntax: start=“value”
E.g.:
<ol <li>Blue</li>
start=‘5’>
</ol>
<li>Red</
li>
<li>Green</
li>
Output 6.Green
5.Red 7.Blue
M V nuvardhan
Ordered Lists – value attribute
It is possible to specify the value of the each list item
using
value attribute
E.g.:
Syntax: <list
type=“value”> values
can be
values can be
Lower-alpha(a,b,c,
…..)
Syntax: list-style-image:url(image_path);
M V nuvardhan
Positioning Markers
To specify the position of the list item markers list-style-
position property of CSS is used
M V nuvardhan
Setting all the properties at
once
List-style property can be used to set all properties at once
e.g.:
Syntax: toplevellist li {
styling
levels
ul ul li{color: blue;}
M V nuvardhan
Description Lists
HTML Description List or Definition List displays
elements in definition form like in dictionary (i.e.,
description).
below:
tag. By default,
nuvardhan
Tables
tr
th th th th th
td td td td Td
td td td td td
M V nuvardhan
Table tags
<caption> is used to set the caption of the table
M V nuvardhan
Scope attribute
The scope attribute specifies whether a header cell is a header
for a column, row, or group of columns or rows. The scope
attribute has no visual effect in ordinary web browsers, but can
be used by screen readers.
E.g.
<table>
<tr>
<th>Sno.</th>
<th scope="col">Month</th>
<th scope="col">Savings</th>
</tr>
<tr>
<td>1</td>
<td>January</td>
<td>$100</td>
</tr>
</table>
M V nuvardhan
Formatting Tables -Borders
A HTML Table can be formatted using CSS
» Border means border of table or border of cell (th, td) the border
property of css is used to set the border.
Syntax
<td rowspan="number">
Syntax
<td colspan="number">
M V nuvardhan
Processing Forms
A form can be processed with the help of client side
and
sever side programming.
M V nuvardhan
Processing Forms
Client side programming:
Server-side Uses:
Displays the requested pages ✓ Interaction with databases
delete, update.
M V nuvardhan
<form> attributes
✓ The action attribute defines the action to be
performed when the form is submitted. Usually, the
form data is sent to a file on the server when the
user clicks on the submit
button. The script can log the information to a
database on the server, send the information via
email, or perform any number of other functions.
M V nuvardhan
<form> attributes contd.
✓ The target attribute specifies where to display the
response
that is received after submitting the form (values -
_self,_blank..).
e.g.
M V nuvardhan
get vs. post
get:
▪ <input> ▪ <button>
▪ <fieldset>
▪ <label>
▪ <legend>
▪ <select>
▪ <option>
▪
▪ <optgroup>
<textarea>
M V nuvardhan
<input> element
Most used form element is the <input> element.
M V nuvardhan
<input> element type attribute
✓ text:defines a single-line text input field.
Syntax:<input type="color">
✓ date:used for input fields that should contain a date.
Depending on browser support, a date picker can show
up in
the input field.
M V nuvardhan
<input> element type attribute
✓ file: defines a file-select field and a "Browse" button
for file uploads.
Syntax:<input type="file">
M V nuvardhan
<input> element other attributes
✓ value: specifies an initial value for an input field
✓ readonly: specifies that an input field is read-only.
✓ disabled: specifies that an input field should be
disabled.
✓ size: specifies the visible width, in characters, of an
input field.
✓ maxlength: specifies the maximum number of
characters allowed in an input field.
M V nuvardhan
<input> element other attributes
✓ placeholder: specifies short a hint that
describes the expected value of an input field
✓ required: specifies that an input field must be filled out
before submitting the form.
✓ autofocus: specifies that an input element should
automatically get focus when the page loads
M V nuvardhan
<form> elements
✓ <label>: element defines a label for several form
elements.
✓ <select>: element defines a drop-down list. For every
option in the list <option> is used
Syntax: <select>
<option></option> . .. . .. .
</select>
</textarea>
✓ <button>: defines a clickable button
button label</button>
M V nuvardhan
<form> elements
✓ <fieldset>: element is used to group related data in a
form.
✓ <legend>: element defines a caption for the <fieldset>
element.
M V nuvardhan
Video in Web pages
HTML5 Supports various formats or codecs.
Eg: <video>
<source src="movie1.mp4" type="video/mp4">
<source src="movie2.ogg" type="video/ogg">
</video>
muted muted Specifies that the audio output of the video should be
muted
NOTE: Autoplay doesn’t work in chrome until you place muted after auto
play
M V nuvardhan
Audio in Web pages
To show a audio in HTML, use the <audio> element:
M V nuvardhan
Audio in Web pages
<source> is used to specify multiple sources
Eg: <audio>
<source src="song1.mp3" type="audio/mp4">
<source src="song2.wav" type="audio/wav">
</audio>
muted muted Specifies that the audio output of the audio should be
NOTE: Autoplay doesn’t work in chrome until you place muted after auto
play
M V nuvardhan
Questions