Unit 2 HTML Code Tantra
Unit 2 HTML Code Tantra
Select all the HTML snippets using <hl> element, that will result in the below output
,-. •iOl
j h1 is what I am
... :t°'\"
~
;tO)"
<°'~
I
<°'~
<°'~ •io~o:
(of~
is ;t0)"
<hl>hl
m what
I am</hl >
. •~(O~
(O'S •io~
<°'~
:t°'\"'
--:i,.,<0~
:to\...
(O'S
of'l<°'\
:to\... ·
I
•io~
:to\...
<hl >hl is what am . </ hl > .~(O~ .
(O'S
:t ~--
mI
io~
hl is what I am </ Hl >
't\<o\
ie)l
<Hl >
<°'~
Q jt Home Learn Anywhere..
e default inline formatting context coalesces the consecutive spaces into one space
-
QI 0
o--------
]-
~
1
index.html O
[email protected] ..
.,ci\.,
as seen previously.
G
The text   ; represents the existence of a non - breaking space
when encountered as part of the HTML code. When displayed,
browsers will replace the string   ; with a single space character
that will not be coalesced with the other consecutive space characters.
Hello World
1
( <strong >Four&nb sp; &nb sp; &n bsp; spaces</ strong>
results in
fl! Terminal m Test cases
Q ~ Home Learn Anywhere• [email protected] .... Support Logout(♦
ement, it is called as a reserved character. When you really need to show that
character to the user, it will not work as expected. This is where we use an entity
•V, •
called as < ; which when displayed by the browser appears like <
~,
0
a::
Entities in HTML are any text that begins with an ampersand (&
character) and ends with a semicolon (; character). They are mostly
used to display invisible characters or reserved characters or symbols
which are not easy to type using typical keyboards.
e
Here's a list of commonly used entities & their type
Entity Description
....
·C
CalJed the non-breaking space, it appears
as an invisible single space character.
LIVE VIEW
- - - - <>~'
' . , .. ,.. r---~, - cw r;:t( mdex.html
------~--
..
. 2 ----- - ---
.,s:,,
Q.
~
p , now that one of the mo~\>ornrnon use cases; of the r > clement 1s to show
ource cod , Howeve,Jf1ec,:mearnng of a
~
J element a~ d1~our;:.ed prcv~~y. ,~
.
'( ~ •:tO:
only lo tnd1cale :that 11s contents are pre formatted & that wh1tespa~~u~ be
d1spla1ed exactly as in the code. On the other hand., to and,cate that a text 1 ,ourcc
cod~e,:Je must u~e the ' > element. thni doc5 not s.ay anything about
. , ,~
. .
.. ~~·nrlespace~ :<~\...
," ·:t~~
The <(;od( > element in HTML is u~ed to wr3p h?~ that 1s m~ant to bl?
<°'~
source code. Commonly., atl te>ct in:.id<? a t, > el'=ment ~) d,,playf.:d
~
:<~\...
by browsers using wNit is called a~ o mono sparred font, one.? whf.?l·'-'...
every character of the te><t h3s th<! nme width . '<°'~.,-
HeieJ ~ a code sn ppet showlng th,, u g :
. ~~'(
Heading l
which browsers d1spl~f i
'(
<h2 > O.\""
The JavaScript e>'.press,on n t 1111 t yhi 1 ( 3 ; declare~ • com,tant by name llead1ng <u>2 </~ ..:
</h2'>
e:f~/•,rr that contains an empty Array obJect
•:t6~'(
~0.\""
'<°'~ •:t6(t.
As can be noted here, there 1s no use of the f r. element as ther~ is no need to
'<°'~
121 Terminnl m Test cases
Q A Home Learn Anywhere • [email protected] • Support Logout C+
6 </p> tO~ ~6 0
a:
-~o.~
used to indicate keyboa rd shortcuts or user input whereas the latter is tO~ ~
osed to indicate the output of a program. ~to.),
?;
QI
tO~ >
He re is a code snippet showing the usage: QI
>
::;
e
I
<pre >$ <kbd >ls -al</ kbd > •
<samp >total 0 ..
drwxr-sr-x 2 ct-4 ct-\Jser 16 Sep 27 04 :48
drwxr-sr-x 3 ct-4 ct-user 15 Sep 27 04:48
</ samp >< / pre > ~0)'
-~o.~
resulting in '<°'~
$ls - al
total 0
drwxr - sr -x 2 c t - 4 c t - user 16 Sep 27 04 : 4 8
dr~xr - sr -x 3 c t - 4 ct - us&r 15 Sep 27 04 : 48
i
What the <kbd > & <samp> elements did is to associate meaning to the text they
e nclosed .
• •tO.''
t 0Vour task ~0)'
1. In the j ndex . html fi le, wrap the keyboard shortcuts Control +A. -~o.~
r _____ ..J , A : - , , l _1, -•----J..-
..ti~
E! Terminal G:I Tc5t casci
Q -8 Home Learn Anywhere • [email protected] • Support Logout[+
0
a:
browsers typically display the text in bold
typeface.
<°'~
~0.\"'
- · - - - - - - - - ~ "'t,.(!J.~
~~-
'(O.~
<p>
<strong >Smoking is prohibited . </ strong >
Do not smoke in this area. Use designated areas f o r smok:
</p >
resulting in
While browsers typically use bold face to display this text, the
element's purpose is not to make the text bold faced (for bold
•\l•-e•~o.\-- LIVE VIEW
facing, one case use CSS). A related element <b> can be used You must ensure that
.I
important things are marked up
if attention has to be drawn to a piece of text without accordingly
enhancing its importance. We use a strong element to
wrap something which is ~<0.\"'
important
<b> element, historically, used to mean bold If it is only to bring visual
1 typeface. However, it now only brings attention to attention, we use a b element!
0
change of meaning to the emphasized words and phrases. A common a:
~I
practice to indicate the same in written texts such as printed books,
magazines, etc. is to italicize the stressed words and phrases. The
<em> element in HTML imparts that meaning to the browser that the
text it wraps has to be stressed when spoken. e
See the below code snippet, that shows two different lines
I <p: em >I </ em > never said she took my stuff <br >
I <em >never </ em > said she too k my stuff
</ p >
--------~---~------~1(6t~
resulting in
~ci,)..
•~O.~
,rO.)--
.~\'.· ~ - LIVE VIEW ~ □
The stress in the first sentence is on the word I where as it is on never in the second
sentence, subtly changing the meaning of the same written sentence, This is an
example of how the <em> element can be used for imparting emphasis to the
relevant part of a text. On one hand the text becomes an interesting read because of
the emphasis, it also benefits those who rely on screen readers where they can voice
0
a:
wraps. Its meaning has been enhanced semantically to
~I
indicate that the text it wraps has a non-textual
~-
annotation (e.g. showing a red squiggly underlining a QI
>
QI
spelling error). >
~
e
See the below code snippet, that indicates spelling errors
<p>
This text has a <u>spaling</u> error, which is marked up in an un'
</ p >
This text has a ~P-aling error, which is marked up in an unarticulated eee LIVE VIEW ~ □
J
annotation. ' I
f I
The most butiful things in the
world cannot be seen or tuched, ri't
l
they are felt with the haart.
1
Note: avoid using this element with its default underline style as
default underlines are visually associated wit~ hyperlinks on the
I I:
internet. When we discuss CSS, styling the <u> element will be
discussed.
l
Your task r
mTerminal e:J Test cases
Q -8 Home Learn Anywhere • [email protected] • Support Logout[+
~ -i-
._o;..,_
. :(0.),
Ramanujan's
LIVE VIEW
.,o.~"'!.°'~
Please make sure to read the terms &
conditions before you agree!
The cat is a domestic animal. It is the only domesticated species v-l.,V'
in the family Felidae. It is commonly referred to as a house cat
to separate it from the other members of the family. t)''
© CodeTantra '!,_6)"'
. "'!.°'~
ti~
13 Terminal m Test cases
Q ~ Home Learn Anywhere "" 12311240.st@lpu .in "" Support Logout[+
2 11 2 Mark element
2.H c7 ~
index.html 0
-
o--------
]- <h3 >Searching · for ·India <lh3 >
1
2 V <p >
~
-----?l <mark>India <lmark>n , · officially ·the ·Republic ·of ·<mark>India <lmark>n , 0
<mark> element in HTML 4 -----?l is ·a · country ·in ·South ·Asia .
represents text which is highlighted 5 -----?l it ·is ~the·seventh - largest ·country ·by ·area ;
6 -----?l the ·most ·populous ·country ·as ·of ·June ·2023 ;
like one marks physical books 7 -----?l and ·from ·the ·time ·of · its ·independence ·in · l 947 ,
using a highlighter. It is commonly 8 -----?l the ·world ' s ·most ·populous·democracy .
9 <Ip > s:Qj
used for highli_ghting a part of a -~
(C)~
10
11
V <p >
-----?l The ·<ma r k>India <lmark>n · subcontinent ·is ·a ·geographical·region ·in · Southern ·Asia , >
larger text. Search results is a QJ
12 -----?l situated ·on · the ·<mark >India <lmark>n · Plate , ·projecting ·southwards·into · t h e ·<mark>Indi a<lmark>n ·Ocean 5
common example 13
i4
-----?l from ·the ·Himalayas .
<Ip>
e
Your task
• In the index.html file, highlight all
occurrences of the text India in the
paragraphs provided using <mar k>
elements
• You must highlight even if there's a eee LIVE VIEW
~
0
a::
of term (the wrapped text inside the <dfn> element) that ~I
is being defined.
<p>
In Physics, <dfn >power</dfn > is defined as the amount of work dor •
</ p> ~'(o.),--
-~'('1-
..o.~
produces the following output
In Physics, power is defined as the amount of work done per unit time.
(O.),•
.~ese LIVE VIEW
o-------- cr,
cr,
::::,
]- 1 V <p > ..0
Q)
2 · · <abbr · title= " Cascading ·Style ·Sheets " >CSS </abbr > · is · a · language · used · to ·style · <a bbr · title = " Hyper · Te x t ·Ma r kup · 0
~
Language " >HTML</abbr> 0
<abbr> element in </p> 10.f'' .,
HTML represents an '<°'~ 0
V,
a:
abbreviation or an
~I
acronym. E.g. HTML is
the short form_of
Hyper Text Markup
Language. An optional
title attribute can be
used to provide the
expansion of the short
form. Typically, some
browsers render the
wrapped text with a :c,0.\'
dotted underline & •.VJ.•~- LIVE VIEW ~□
some browsers also ~'<ii. , CSS is a language used to style
HTML
display the text in
upper case. It is a good
practice to include the
expansion on the first
use of the abbreviation
in a HTML page.
E! Termina l ~ Test cases
Q ~ Home Learn Anywhere • [email protected] • Support ·'. logo~tC+
• Unordered lists (<ul> elements) are meant to be used to categorize items whose order does not matter
• Ordered lists (<ol> elements) on the other hand are for items whose order does matter
ctrl + k
• Description lists (<dl> elements) are meant for lists of terms & their descriptions
G 2.1.8. emphasis, italics • Data lists (<datalist> elements) are for restricting the options from which the values of other controls can be
selected
G 2.1.9. underline or unarticulated annotation
G 2.1.10. Subscript, superscript Select the best match for the values in the two columns of the table below
G 2.1 .11 . Small element
1. A selection list from which parts of a computer to be :t6\"'
a. <ul> •:tO.~
G 2.1.12. Mark element purchased are selected
(6~
G 2.1.13. Definition element 0.\"' 2. Some scientific terms & their defin itions b. <ol>
G 2.1.14. Abbreviation element
'(\'(6\"'
3. Ingredients of a dish c. <dl>
A
tO
4. Steps of an algorithm d.<datalist>
I
G 2.2.3. Unordered lists - bullet type
Q 1a,2b, 3c,4d
G 2.2.4. Ordered lists
:t6\"'
G 2.2.5. Ordered lists - type attribute 1 d, 2c, 3b, 4a · o.~
~ 3. HTML - continued A
- - ffln - - ..
Q * Home Learn Anywhere .... [email protected] .... Support Logout c+
o--------
]- 1 <h3 >India ' s ·western ·neighbo urs </h3 >
2 <ul >
~ 3
The <ul> element, called an unordered list is <li >Maldives </li >
0 2.1.9. underline or unarticu lated annotation
5 <li >Afghanistan </li >
used to represent a group of items w hose
6 <li >Pakistan </li >
G 2.1.10. Subscript, superscript order has no meaning or value. Browsers </ul >
0 2.2.3. Unordered lists - bullet type children, one each for every one of the items eee LIVE VIEW
in the group.
0 2.2.4. Ordered lists India's western
neighbours
0 2.2.s . Ordered lists - type attribute The code snippet below
• Maldives
0 2.2.6. Ordered lists - start attribute <h3 >Parts of a flo we r< /h3 > • Afghanistan
<ul > • Pakistan
0 2.2.7. Nested lists <li >Stigma </li >
<li >Style </li >
0 2.2.8. Descriptio n lists
<li >Petals </ li >
<li >Sepals </li >
N ut...)...,_
Q * Home Learn Anywhere • [email protected] • Support Logout(♦
~
v -~-------
__
eighbo u rs< /h 3>
- type : squa re " > 0
::::,
..0
QI
4
5
!::::::::;:;:::::::=~::==.::;=:;:=' >1 •
exercise, we will briefly touch upon changing the bullet 0"'
G 2.1.11. Small element a:
type but more detail can be found in the CSS sectio n. ~
.., G 2.1.12. Mark element '<°'~
.,o.\; ~
G 2.1.13. Definition element •iO.~ (IJ
tO.~
t<>~ list-style-type CSS property (CSS properties >QI
>
G 2.1.14. Abbreviation element ~
will be discussed as part of the CSS section)
e
allows one to change the bullet type. Some of
I 2.2. Lists A
the possible values of this property are: disc,
G 2.2. 1. Lists circle, square . The default value is disc.
G 2.2.2. Unordered lists
■ Maldives
G 2.2.7. Nested lists
■ Afghanistan
■ Pakistan
G 2.2.8. Description lists
Q 3. HTML - continued A
Q 3.1. Hyperlinks V
0 index.html 0
QJ 0
o--------
]- 1 <h3 >How ·t o·coo k · rice ·without · a ·pressure · cooker? < /h3 >
<o l >
~
<li >Rinse ·the · rice</li>
The <o l> element, called an ordered list is used to represent a list of <li >Mix ·water · to · rice · in · a · 2 : 1 · ratio</li>
items whose order is meaningful. Browsers render an ordered list as a <li >Heat·the ·mixture · t o ·boil</li> V,
As with the <ul> element, each individual item ofthe ordered list also must be
represented by a list item.
I
<li> or list item element wraps each of the items in the ordered list.
Every <ol> element must have one or more <li> children, one each
2.2 5. Ordered lists - type attribute ~-~~ :_::-=:_~= c:> - QJ (FJ index.html 0 :tO.\"' 0 ai
0 •iO.~ O"I
0..
X 1 <h3 >Table · of ·Contents</h3> ..,o.~ O"I
:J
..c
LJ.J QJ
2 v <ol · type= " I " > D
~
3 ·<li>Introduction</li> 0
The type attribute of an <ol> element sets the numbering type of
· · <li>About < /li>
lo>)'
the list. This allows changing from decimal numbering to Roman 5 ·< li>Taxonomy</li> VI
,. .o.\. .
. -~'<o. :tO.\"'
1. The file index . html is listing a table of contents (TOC) .,0,'y.
~~~
'(o."S
E!!I Terminal EE Test cases
Q ~ Home Learn Anywhere... [email protected] ... Support Logout[♦
2.2.6. Ordered lists - start attribute ~~i~J}~~,· d> - w (§:I index.html 0 0 Cl)
o--------
]-
1 <h3>Table ·o f · Contents , · continued</h3>
0)
0)
::::,
..Cl
metimes a list may have to start at a position different from the first step. This 2 v <o l · type= " I " ·start= " 4 " > 0
Cl)
appens generally when a list is broken into 2 different <ol> elements for, various ~ 3 · · <li>Biology</li> 0
· · <li > Dornestic ·Species ~ /li>
reasons. In such cases, the list items will have to continue their numbering rather than · · <l i >Wild ·Species</,J..i> VI
· start from 1 again. The start attribute allows us to do that. < /ol> 0
C:
~I
The start attribute of an <ol> element configures the value from
which to start counting the list item children of an ordered list. This
value must always be a decimal number regardless of the value of the
type attribute. i.e. <ol type = " a " start= "-3 " > is a correct usage _& e
the first item will start with c .
Your task
,.o.~ 1. The file index . html is listing a table of contents (TOC)
2. Change the numbering type of the TOC to upper-caie Roman numerals & . (O.\
make the list start at IV . •:\L.• e e LIVE VIEW
0,,...
Table of Contents,
continued
IV. Biology
V. Domestic Species
VI. Wild Species
~O,~(
E!!I Terminal Ee Test cases
Q ~ Home
-
Learn Anywhere ... [email protected] ... Support Logout(+
f°l>
..0
a,
hether with ordered lists or unordered ones, it is possible to nest lists inside other 0
~
ts. A common use-case for this is when we have a step broken into multiple further
steps. It is also possible to nest ordered lists inside unordered ones & the other way
v <li >Chapter · l
v <o l >
·~... ••
5 <li >Se cti o n · l . l < /li> 1/)
· round too. 0
6 <li >Sec ti o n- · l . 2< /µ i > ..,.o.~:(~ 0:::
The below snippet contains an algorithm to compute the factorial of a positive </ o l >
:;1
< /li >
'<°'~
integer
::a,
10
<ol >
1,1 <li >Chapter ·2 :tO.\"' >a,
<li >Read positive integer n</li> •:tO.~ >
12 <o l > :.::;
<li >Initialize index & prod to 1</ li > '<°'~
<li >Increment index by 1 </li >
13 <li >,S ection · 2 . 1</li> G,
14 </ ol >
<li >
15 < /li >
Verify if index reached n
i6
<ul >
17 ..,.o.~:tO.\"' :tO.\"'
<li>If index <= n, go to step 5</ li >
<li >If index > n, go to step 7</ li >
18 '<°'~ •N-'I:
•:tO.~
</ ul>
'<°'~
</li>
<li >Store the result in prod for the product of prod &. index</ li > ~0.\"'
·i''<o
<li >Go to step 3</li>
<li >Return the value of prod as the factorial of n</li >
</ ol >
'<°'~
IV!
•.e• cO.\"'
LIVE V IEW ~ □
I . (o.~' 0
a::
lists such as frequently asked questions & their answers <dt>Oxymoro n</dt>
~I
<dd>A ·phrase · that ·uses·two ·contradictory·words ·to ·create ·a ·new ·meaning</dd>
</dl>
While the <dl> element represents the list of terms, each individual term
itself is represented by a description term or <dt> element & the
corresponding description being wrapped in a <dd> element.
e
<dt> or description term element wraps the text of the term ,.~'( ~,
which is defined/described by the contents of <dd> or (VI