0% found this document useful (0 votes)
5 views20 pages

HTML Lesson4

This document provides a comprehensive overview of HTML lists, including unordered, ordered, and description lists, along with their respective tags and examples. It also covers HTML text formatting elements such as bold, italic, subscript, and superscript, as well as color specifications using various methods like RGB and HEX. Additionally, it includes examples of setting background colors, text colors, and border colors in HTML.

Uploaded by

sawsan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views20 pages

HTML Lesson4

This document provides a comprehensive overview of HTML lists, including unordered, ordered, and description lists, along with their respective tags and examples. It also covers HTML text formatting elements such as bold, italic, subscript, and superscript, as well as color specifications using various methods like RGB and HEX. Additionally, it includes examples of setting background colors, text colors, and border colors in HTML.

Uploaded by

sawsan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HTML Lesson4

HTML Lists
HTML lists allow web developers to group a set of related items in
lists.

Example
An unordered HTML list:

 Item
 Item
 Item
 Item

An ordered HTML list:

1. First item
2. Second item
3. Third item
4. Fourth item

>!DOCTYPE html<

>html<

>body<

>h2>An Unordered HTML List</h2<

>ul<

>li>Coffee</li<

>li>Tea</li<

>li>Milk</li<

>/ul<

>h2>An Ordered HTML List</h2<

>ol<
>li>Coffee</li<

>li>Tea</li<

>li>Milk</li<

>/ol<

>/body<

>/html<

Output(‫)التنفيذ‬

An Unordered HTML List

 Coffee
 Tea
 Milk

An Ordered HTML List

1. Coffee
2. Tea
3. Milk

1-Unordered HTML 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:

Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
2- Ordered HTML 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:

Example
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>

3-HTML Description Lists


HTML also supports description lists.

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:

Example
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>

<!DOCTYPE html>

<html>

<body>

<h2>A Description List</h2>

<dl>

<dt>Coffee</dt>
<dd>- black hot drink</dd>

<dt>Milk</dt>

<dd>- white cold drink</dd>

</dl>

</body>

</html>

output

A Description List
Coffee

- black hot drink

Milk

- white cold drink

HTML List Tags

Tag Description

<ul> Defines an unordered list

<ol> Defines an ordered list

<li> Defines a list item

<dl> Defines a description list


<dt> Defines a term in a description list

<dd> Describes the term in a description list

Exercise:
Add a list item with the text "Coffee" inside the <ul> element.

<ul> Coffee </ul>


Ans:

Add a list item with the text "Coffee" inside the <ul>.

<ul>

<il>coffee</il>

</ul>

Add a list item with the text "Coffee" inside the <ul>.Add a list item
with the text "Coffee" inside the <ul>.

HTML Text Formatting

HTML contains several elements for defining text with a special


meaning.

Example
This text is bold

This text is italic

This is subscript and superscript


<!DOCTYPE html>

<html>

<body>

<p><b>This text is bold</b></p>

<p><i>This text is italic</i></p>

<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>

</body>

</html>

output

This text is bold

This text is italic

This is subscript and superscript

HTML Formatting Elements


Formatting elements were designed to display special types of text:

 <b> - Bold text


 <strong> - Important text
 <i> - Italic text
 <em> - Emphasized text
 <mark> - Marked text
 <small> - Smaller text
 <del> - Deleted text
 <ins> - Inserted text
 <sub> - Subscript text
 <sup> - Superscript text

HTML <b> and <strong> Elements


The HTML <b> element defines bold text, without any extra importance.
Example
<b>This text is bold</b>

<!DOCTYPE html>

<html>

<body>

<p>This text is normal.</p>

<p><b>This text is bold.</b></p>

</body>

</html>

The HTML <strong> element defines text with strong importance. The
content inside is typically displayed in bold.

Example
<strong>This text is important!</strong>

<!DOCTYPE html>

<html>

<body>

<p>This text is normal.</p>

<p><strong>This text is important!</strong></p>

</body>

</html>

HTML <i> and <em> Elements


The HTML <i> element defines a part of text in an alternate voice or
mood. The content inside is typically displayed in italic.

Tip: The <i> tag is often used to indicate a technical term, a phrase
from another language, a thought, a ship name, etc.
Example
<i>This text is italic</i>

<!DOCTYPE html>

<html>

<body>

<p>This text is normal.</p>

<p><i>This text is italic.</i></p>

</body>

</html>

The HTML <em> element defines emphasized text. The content inside is
typically displayed in italic.

Tip: A screen reader will pronounce the words in <em> with an


emphasis, using verbal stress.

Example
<em>This text is emphasized</em>

<!DOCTYPE html>

<html>

<body>

<p>This text is normal.</p>

<p><em>This text is emphasized.</em></p>

</body>

</html>

HTML <small> Element


The HTML <small> element defines smaller text:

Example
<small>This is some smaller text.</small>
Try it Yourself »

<!DOCTYPE html>

<html>

<body>

<p>This is some normal text.</p>

<p><small>This is some smaller text.</small></p>

</body>

</html>

HTML <mark> Element


The HTML <mark> element defines text that should be marked or
highlighted:

Example
<p>Do not forget to buy <mark>milk</mark> today.</p>

<!DOCTYPE html>

<html>

<body>

<p>Do not forget to buy <mark>milk</mark> today.</p>

</body>

</html>

HTML <del> Element


The HTML <del> element defines text that has been deleted from a
document. Browsers will usually strike a line through deleted text:

Example
<p>My favorite color is <del>blue</del> red.</p>

<!DOCTYPE html>

<html>
<body>

<p>My favorite color is <del>blue</del> red.</p>

</body>

</html>

HTML <ins> Element


The HTML <ins> element defines a text that has been inserted into a
document. Browsers will usually underline inserted text:

Example
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>

<!DOCTYPE html>

<html>

<body>

<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>

</body>

</html>

HTML <sub> Element


The HTML <sub> element defines 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:

Example
<p>This is <sub>subscripted</sub> text.</p>

Try it Yourself »

!DOCTYPE html>

<html>

<body>
<p>This is <sub>subscripted</sub> text.</p>

</body>

</html>

HTML <sup> Element


The HTML <sup> element defines 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,
like WWW[1]:

Example
<p>This is <sup>superscripted</sup> text.</p>

Try it Yourself »

<!DOCTYPE html>

<html>

<body>

<p>This is <sup>superscripted</sup> text.</p>

</body>

</html>

HTML Text Formatting Elements

Tag Description

<b> Defines bold text


<em> Defines emphasized text

<i> Defines a part of text in an alternate voice or mood

<small> Defines smaller text

<strong> Defines important text

<sub> Defines subscripted text

<sup> Defines superscripted text

<ins> Defines inserted text

<del> Defines deleted text

<mark> Defines marked/highlighted text


HTML Colors

HTML colors are specified with predefined color names, or with RGB,
HEX, HSL, RGBA, or HSLA values.

Color Names

In HTML, a color can be specified by using a color name:

Tomato

Orange

DodgerBlue

MediumSeaGreen

Gray
SlateBlue

Violet

LightGray
!DOCTYPE html>

<html>

<body>

<h1 style="background-color:Tomato;">Tomato</h1>

<h1 style="background-color:Orange;">Orange</h1>

<h1 style="background-color:DodgerBlue;">DodgerBlue</h1>

<h1 style="background-color:MediumSeaGreen;">MediumSeaGreen</h1>

<h1 style="background-color:Gray;">Gray</h1>

<h1 style="background-color:SlateBlue;">SlateBlue</h1>

<h1 style="background-color:Violet;">Violet</h1>

<h1 style="background-color:LightGray;">LightGray</h1>

</body>

</html>

Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray

Background Color

You can set the background color for HTML elements:

Hello World

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Example
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">Lorem ipsum...</p>

<!DOCTYPE html>

<html>

<body>

<h1 style="background-color:DodgerBlue;">Hello World</h1>


<p style="background-color:Tomato;">

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed


diam nonummy nibh euismod tincidunt ut laoreet dolore magna
aliquam erat volutpat.

Ut wisi enim ad minim veniam, quis nostrud exerci tation


ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo
consequat.

</p>

</body>

</html>

Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Text Color

You can set the color of text:

Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat.

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper


suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Example
<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>
<!DOCTYPE html>

<html>

<body>

<h3 style="color:Tomato;">Hello World</h3>

<p style="color:DodgerBlue;">Lorem ipsum dolor sit amet,


consectetuer adipiscing elit, sed diam nonummy nibh euismod
tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>

<p style="color:MediumSeaGreen;">Ut wisi enim ad minim veniam,


quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut
aliquip ex ea commodo consequat.</p>

</body>

</html>

Hello World

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat.

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper


suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Border Color
You can set the color of borders:

Hello World
Hello World
Hello World
Example
<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>

<!DOCTYPE html>

<html>

<body>

<h1 style="border: 2px solid Tomato;">Hello World</h1>

<h1 style="border: 2px solid DodgerBlue;">Hello World</h1>

<h1 style="border: 2px solid Violet;">Hello World</h1>

</body>

</html>

Hello World
Hello World
Hello World
Color Values
In HTML, colors can also be specified using RGB values, HEX values,
HSL values, RGBA values, and HSLA values.

The following three <div> elements have their background color set
with RGB, HEX, and HSL values:

rgb(255, 99, 71)

#ff6347
hsl(9, 100%, 64%)
The following two <div> elements have their background color set with
RGBA and HSLA values, which adds an Alpha channel to the color
(here we have 50% transparency) (255, 99, 71, 0.5) (255,
99, 71, 0.5)

Example
<h1 style="background-color:rgb(255, 99, 71);">...</h1>
<h1 style="background-color:#ff6347;">...</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">...</h1>

<h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1>


<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1>

<!DOCTYPE html>

<html>

<body>

<p>Same as color name "Tomato":</p>

<h1 style="background-color:rgb(255, 99, 71);">rgb(255, 99,


71)</h1>

<h1 style="background-color:#ff6347;">#ff6347</h1>

<h1 style="background-color:hsl(9, 100%, 64%);">hsl(9, 100%,


64%)</h1>

<p>Same as color name "Tomato", but 50% transparent:</p>

<h1 style="background-color:rgba(255, 99, 71, 0.5);">rgba(255,


99, 71, 0.5)</h1>

<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">hsla(9,


100%, 64%, 0.5)</h1>
<p>In addition to the predefined color names, colors can be
specified using RGB, HEX, HSL, or even transparent colors using
RGBA or HSLA color values.</p>

</body>

</html>

Same as color name "Tomato":

rgb(255, 99, 71)


#ff6347
hsl(9, 100%, 64%)
Same as color name "Tomato", but 50% transparent:

rgba(255, 99, 71, 0.5)


hsla(9, 100%, 64%, 0.5)
In addition to the predefined color names, colors can be specified using
RGB, HEX, HSL, or even transparent colors using RGBA or HSLA color
values.

You might also like