Web Design Unit 1
Web Design Unit 1
What is HTML?
HTML is a standard markup language which is used for creating web pages.
It provides some titles, headings, paragraphs, lists, tables, embedded images, etc., to
describe the structure of text-based and multimedia information in HTML
documents.
HTML was first created by Tim Berners-Lee, Robert Cailliau, and others starting in
1986.
Berners-Lee specified HTML and wrote the browser and server software in late 1990.
Year Version
www.RNWMULTIMEDIA.com Page | 1
1. HTML 1.0 :
o HTML 1.0 or first version of HTML was a version of SGML that had ability to link
different document or pages using 'href'.
o HTML 1.0 had 20 elements or tags, now latest version of HTML, ie HTML5 has a lot
more.
2. HTML 2.0 :
o After HTML 1.0, the second version of HTML was released in 1994. HTML 2.0 was
an expansion of HTML 1.0.
3. HTML 3.2 :
o HTML 3.2 was released In 1997. HTML 3.2 had many new features like tables,
superscript, subscript etc.
o Two most important features introduced in HTML 3.2 were tables and text flow
around images.
o Tables were widely used and programmers still use them but it is not recommended
anymore.
4. HTML 4.01 :
o HTML 4.01 was released In 1999. HTML 4.01 introduced features like scripting,
style sheets, better tables, better forms frames and embedding objects.
o HTML 4.01 was a revised version of HTML 4.0, it also included features for the
disabled people to enhance their interactivity with the Global world through Internet.
5. XHTML :
o In 2000 XHTML was released. XHTML stands for Extensible Hyper Text Markup
Language.
o XHTML has strict set of rules and it is basically an XML application of HTML.
6. HTML5 :
o So all of this added up and then after so many year HTML5 was released in 2014.
o HTML5 is the best version of HTML up till now. HTML5 improved user interactivity
so much and also lessened the burden of devices.
www.RNWMULTIMEDIA.com Page | 2
Difference between HTML and HTML5 :
HTML HTML5
HTML Doctype declaration is lengthy. DOCTYPE declaration in HTML5 is simple.
Attributes like async, charset, and ping are Attributes of async, ping, charset, and are a
not present in HTML. part of HTML5.
HTML does not allow drag and drop effects. HTML5 allows drag and drop effects.
Built based on Standard Generalized Markup HTML5 has improved parsing rules providing
Language (SGML). enhanced compatibility.
The type attribute for < script > and < link > The type attribute for < script> and < link > tag
tag is mandatory in the code. can be omitted in the code.
< Html >, < body >, < head > tags are < Html >, < body >, < head > tags can be
mandatory while coding. omitted while coding.
www.RNWMULTIMEDIA.com Page | 3
1.2 Create and save an HTML document, access a web page using a web
browser :
".html" or ".htm" are the two extensions used to write and save HTML files; we
can write HTML code in any text editor and save it as "filename.html" or
"filename.htm".
Requirements:
1. Text Editor
2. An Internet Browser
You can write HTML in any simple editor such as Notepad. And other software such
as Adobe Dreamweaver, Sublime, NetBeans, Notepad ++, etc., are mainly used for
writing and editing HTML.
There are a few important things to keep in mind when you save it the file:
Don’t use any spaces or special characters in the file name. Use underscores (_) or
dashes (-) instead.
Decide where in your computer you will save the file, and make sure to remember the
location!
www.RNWMULTIMEDIA.com Page | 4
1.3 Structure of HTML page :
1. <!DOCTYPE>
2. <html>
3. <head>
4. <title>
5. <body>
1. The DOCTYPE :
The DOCTYPE tells the web browser which version of HTML the page is written
in.
www.RNWMULTIMEDIA.com Page | 5
2. The <html> Element :
The <html> element tells the browser that the page will be formatted in HTML
and, optionally, which world language the page content is in.
The <head> element surrounds all the special “behind the scenes” elements of a
web document.
Most of these elements do not get displayed directly on the web page.
The <body> element surrounds all the actual content (text, images, videos, links,
etc.) that will be displayed on our web page.
This line declares that the document is encoded in the UTF-8 (Unicode) character
set.
www.RNWMULTIMEDIA.com Page | 6
There can be multiple <meta> lines in the same web page.
The <meta> element is often used to provide additional information such as page
keywords, a page description, and the author(s) of a web document.
The <title> element defines what text will show in the web browser’s title bar :
An HTML element is defined by a start tag, some content, and an end tag :
The HTML element is everything from the start tag to the end tag :
Note : Some HTML elements have no content (like the <br> element). These
elements are called empty elements. Empty elements do not have an end tag!
www.RNWMULTIMEDIA.com Page | 7
1. HTML Headings tag:
<h1> defines the most important heading. <h6> defines the least important
heading:
Example : Output :
<!DOCTYPE html>
<html>
This is heading 1
<body>
This is heading 2
<h1>This is heading 1</h1>
<h2>This is heading 2</h2> This is heading 3
<h3>This is heading 3</h3>
This is heading 4
<h4>This is heading 4</h4>
<h5>This is heading 5</h5> This is heading 5
<h6>This is heading 6</h6>
This is heading 6
</body>
</html>
Example : Output :
Some HTML tags are not closed, for example br and hr.
<br> Tag : br stands for break line, it breaks the line of the code.
<hr> Tag : hr stands for Horizontal Rule. This tag is used to put a line across the
webpage.
www.RNWMULTIMEDIA.com Page | 8
4. HTML Formatting Elements :
Tag Description
<b> Bold text
<strong> Important text
<i> Italic text
<u> Underline text
<tt> Teletype text
<em> Emphasized text
<mark> Marked (Heighlight) text
<small> Smaller text
<big> Bigger text
<del> , <s> Deleted text , Strike text
<ins> Inserted text
<sub> Subscript text
<sup> Superscript text
<q> Short Quotations text
Tag Description
<address> Contact information.
<article> Article content.
<aside> Aside content.
<blockquote> Long ("block") quotation.
<div> Document division.
<nav> Contains navigation links.
<header> Section or page header.
<footer> Section or page footer.
<form> Input form.
<table> Create Table.
<h1 to <h6> Heading levels 1-6.
<hr> Horizontal rule (dividing line).
<p> Paragraph.
<pre> Preformatted text.
<section> Section of a web page.
www.RNWMULTIMEDIA.com Page | 9
6. HTML List Tag :
Unordered List :
Type Description
Type "disc" This is the default style. the list items are marked with bullets.
Type "circle" In this style, the list items are marked with circles.
Type "square" In this style, the list items are marked with squares.
Type "none" In this style, the list items are not marked .
www.RNWMULTIMEDIA.com Page | 10
Example : Example : Example :
Default(Disc Bullets) Circle Bullets Square Bullets
1. <ul> 1. <ul type="circle"> 1. <ul type="square">
2. <li>HTML</li> 2. <li>HTML</li> 2. <li>HTML</li>
3. <li>Java</li> 3. <li>Java</li> 3. <li>Java</li>
4. <li>JavaScript</li> 4. <li>JavaScript</li> 4. <li>JavaScript</li>
5. <li>SQL</li> 5. <li>SQL</li> 5. <li>SQL</li>
6. </ul> 6. </ul> 6. </ul>
Ordered List :
Type Description
Type "1" This is the default type. The list items are numbered with numbers.
Type "I" In this type, the list items are numbered with upper case roman numbers.
Type "i" In this type, the list items are numbered with lower case roman numbers.
Type "A" In this type, the list items are numbered with upper case letters.
Type "a" In this type, the list items are numbered with lower case letters.
www.RNWMULTIMEDIA.com Page | 11
The start Attribute :
o You can use start attribute for <ol> tag to specify the starting point of
numbering you need.
o Following are the possible options −
Example :
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = "i" start = "4">
<li> HTML </li>
<li> PHP </li>
<li> Android </li>
<li> JavaScript </li>
</ol>
</body>
</html>
Output :
iv. HTML
v. PHP
vi. Android
vii. JavaScript
Descriptive List :
www.RNWMULTIMEDIA.com Page | 12
1. Example :
2. <dl>
3. <dt>HTML</dt>
4. <dd>is a markup language</dd>
5. <dt>Java</dt>
6. <dd>is a programming language and platform</dd>
7. <dt>JavaScript</dt>
8. <dd>is a scripting language</dd>
9. <dt>SQL</dt>
10. <dd>is a query language</dd>
</dl>
Output :
HTML
is a markup language
Java
is a programming language and platform.
JavaScript
is a scripting language
SQL
is a query language
Tag Description
<table> It defines a table.
<tr> It defines a row in a table.
<th> It defines a header cell in a table.
<td> It defines a cell in a table.
<caption> It defines the table caption.
<tbody> It is used to group the body content in a table.
<thead> It is used to group the header content in a table.
<tfooter> It is used to group the footer content in a table.
www.RNWMULTIMEDIA.com Page | 13
Example :
<!DOCTYPE html>
<html>
<body>
<table border =”5”>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Priya</td>
<td>Sharma</td>
<td>24</td>
</tr>
<tr>
<td>Arun</td>
<td>Singh</td>
<td>32</td>
</tr>
<tr>
<td>Sam</td>
<td>Watson</td>
<td>41</td>
</tr>
</table>
</body>
</html>
Output :
www.RNWMULTIMEDIA.com Page | 14
Table Tag Properties (Attributes) :
Properties Description
Border border attribute of table tag in HTML to specify border.
Align It specify table Alignment (Left , Right ,Center).
Height It specify the HTML table Height (pixels or percentage).
Width It specify the HTML table width (pixels or percentage).
Bgcolor It specify background color for table.
Background It specify background image for table.
Cellpadding It specify padding for table header and table data.
Cellspacing It specify Space for table in between cell.
Rowspan It will divide a cell into multiple rows.
The number of divided rows will depend on rowspan values.
It used in <th> or <td> tag.
Colspan It will divide a cell into multiple Columns.
The number of divided columns will depend on colspan values.
It used in <th> or <td> tag.
The HTML <form> element is used to create an HTML form for user input.
Syntax :
<form>
//form elements
</form>
o The action attribute defines the action to be performed when the form is
submitted.
o Usually, the form data is sent to a file on the server when the user clicks on
the submit button.
www.RNWMULTIMEDIA.com Page | 15
2. The Method Attribute :
In GET method we can not send large In POST method large amount of
amount of data rather limited data is sent data can be sent because the request
because the request parameter is appended parameter is appended into the body.
into the URL.
Request made through GET method are Request made through POST method
stored in Browser history. is not stored in Browser history.
GET method request can be saved as POST method request can not be
bookmark in browser. saved as bookmark in browser.
Request made through GET method are Request made through POST method
stored in cache memory of Browser. are not stored in cache memory of
Browser.
Data passed through GET method can be Data passed through POST method
easily stolen by attackers. can not be easily stolen by attackers.
In GET method only ASCII characters are In POST method all types of data is
allowed. allowed.
www.RNWMULTIMEDIA.com Page | 16
The <form> element can contain one or more of the following form elements:
Tag Description
Example :
<html>
<body>
<form method="post">
<fieldset>
<legend> User Information: </legend> <br>
www.RNWMULTIMEDIA.com Page | 17
<label for="Gender">Gender:</label>
<input type="radio" id="male" name="gender" value="Male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="FeMale">
<label for="female">FeMale</label> <br><br>
<label for="hobby">Hobby:</label>
<input type="checkbox" name="hobby1" value="Reading">
<label for="hobby1"> Reading</label>
<input type="checkbox" name="hobby2" value="Shopping">
<label for="hobby2"> Shopping</label>
<input type="checkbox" name="hobby3" value="Travelling" checked>
<label for="hobby3"> Travelling</label> <br> <br>
</fieldset>
</form>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 18
9. HTML Frame tag :
HTML <frame> tag define the particular area within an HTML file where another
HTML web page can be displayed.
A <frame> tag is used with <frameset>, and it divides a webpage into multiple
sections or frames, and each frame can contain different web pages.
Example :
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>Frame tag</title>
5. </head>
6. <frameset cols="25%,50%,25%">
7. <frame src="frame1.html" >
8. <frame src="frame2.html">
9. <frame src="frame3.html">
</frameset>
</html>
Output :
www.RNWMULTIMEDIA.com Page | 19
Frame Tag attributes :
Attribute Description
Frameborder It specifies whether to display a border around the frame or not, and its
default value is 1
Src It specifies the URL of the document which we want to display in a frame.
Example : Output :
</body>
</html>
www.RNWMULTIMEDIA.com Page | 20
11. HTML Bookmarks :
<html>
<body>
Bookmark example <br>
<a href="#bottom">GoTo Bottom</a>
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
Attribute Description
Hspace white space to be inserted to the left and right of the object.
Vspace white space to be inserted to the top and bottom of the object.
www.RNWMULTIMEDIA.com Page | 21
Example :
<!DOCTYPE html>
<html>
<head>
<title>HTML Tag</title>
</head>
<body>
<img src = https://www.tutorialspoint.com/images/html.gif alt = "HTML Tutorial"
height = "150" width = "140" />
</body>
</html>
Output :
What is CSS ?
CSS describes how HTML elements are to be displayed on screen, paper, or in other
media.
CSS saves a lot of work. It can control the layout of multiple web pages all at once.
CSS is designed to enable the separation of presentation and content, including layout,
colors, and fonts.
CSS Benefits :
www.RNWMULTIMEDIA.com Page | 22
CSS Syntax :
Each declaration includes a CSS property name and a value, separated by a colon.
Multiple CSS declarations are separated with semicolons, and declaration blocks are
surrounded by curly braces.
Example :
In this example all <p> elements will be center-aligned, with a red text color:
p{
color: red;
text-align: center;
}
CSS selectors are used to "find" (or select) the HTML elements you want to style.
1) The element selector selects HTML elements based on the element name.
Example :
In this example all <p> elements will be center-aligned, with a red text color:
p{
color: red;
text-align: center;
}
www.RNWMULTIMEDIA.com Page | 23
2) The element selector selects HTML elements based on the id.
To select an element with a specific id, write a hash (#) character, followedby
the id of the element.
Example :
The CSS rule below will be applied to the HTML element with id="pa1":
#pa1 {
text-align: center;
color: red;
}
The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by
the class name.
Example :
The CSS rule below will be applied to the HTML element with class="pa1":
.pa1 {
text-align: center;
color: red;
}
Example :
The CSS rule below will affect every HTML element on the page:
*{
text-align: center;
color: blue;
}
www.RNWMULTIMEDIA.com Page | 24
5) Grouping Selector :-
The grouping selector selects all the HTML elements with the Same style
definitions.
Example :
In this example we have grouped the selectors from the code above:
h1, h2, p {
text-align: center;
color: red;
}
You can also apply styles to HTML elements with particular attributes.
Example :
This style rule will match all the input elements having a type attribute with a value
of text color.
input[type = "text"] {
color: #000000;
}
1. Inline CSS
2. External CSS
3. Internal CSS
1) Inline CSS :
An inline style may be used to apply a unique style for a single element.
To use inline styles, add the style attribute to the relevant element.
www.RNWMULTIMEDIA.com Page | 25
Example :
Inline styles are defined within the "style" attribute of the relevant element:
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue; text-align:center;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
2) External CSS:
With an external style sheet, you can change the look of an entire
website by changing just one file!
Each HTML page must include a reference to the external style sheet file inside
the <link> element, inside the head section.
An external style sheet can be written in any text editor, and must be saved with a
.css extension.
The external .css file should not contain any HTML tags.
Example :
External styles are defined within the <link> element, inside the <head> section
of an HTML page:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="mystyle.css">
</head>
<body>
<h1>This is aheading</h1>
<p>This is aparagraph.</p>
</body>
</html>
"mystyle.css"
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
www.RNWMULTIMEDIA.com Page | 26
3) Internal CSS:
An internal style sheet may be used if one single HTML page has a unique style.
The internal style is defined inside the <style> element, inside the head section.
Example :
Internal styles are defined within the <style> element, inside the <head> section
of an HTML page:
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: linen;
}
h1 {
color:
maroon;
margin-left:
40px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 27
Cascading Order :
All the styles in a page will "cascade" into a new "virtual" style sheet by the
following rules, where number one has the highest priority:
3. Browser default.
Example :
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<style>
body {background-color: yellow;}
</style>
</head>
<body style="background-color: lavender">
<h1>Multiple Styles Will Cascade into One</h1>
<p>Here, the background color of the page is set with inline CSS, and also with an
internal CSS, and also with an external CSS. </p>
<p>Try experimenting by removing styles to see how the cascading styles heets work
(try removing the inline CSS first, then the internal, then the external). </p>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 28
CSS property :
1) CSS Color :
1.1 CSS Background Color : Thisproperty is used to set the background color of
anelement.
Example :
<html>
<head>
</head>
<body>
<pstyle="background-color:yellow;">
This text has a yellow background color.
</p>
</body>
</html>
Output :
www.RNWMULTIMEDIA.com Page | 29
1.2 CSS Text Color : The color property is used to set the color of a text.
Example :
<html>
<head>
</head>
<body>
<pstyle="color:red;">
This text will be written in red.
</p>
</body>
</html>
Output :
2) CSS Background :
The CSS background properties are used to add background effects for
elements.
www.RNWMULTIMEDIA.com Page | 30
Example :
<html>
<head>
<style>
body {
background-image: url("img_tree.png");
background-repeat: no-repeat; //value : repeat,repeat-x,repeat-y
background-position: right top;
background-attachment: fixed;//scroll
}
</style>
</head>
<body>
<p>Tutorials point</p>
</body>
</html>
3) CSS Border :
The border properties allow you to specify how the border of the box
representing an element should look.
There are three properties of a border you can change :
The border-color:
The border-color property allows you to change the color of the border surrounding
an element.
www.RNWMULTIMEDIA.com Page | 31
Example :
<html>
<head>
<styletype="text/css">
p.e1 {
border:1px solid;
border-bottom-color: green;
border-top-color: red;
border-left-color: black;
border-right-color: blue;
}
p.e2 {
border:1px solid;
border-color: green;
}
</style>
</head>
<body>
<pclass="e1">
This example is showing all borders in different colors.
</p>
<pclass="e2">
This example is showing all borders in green color only.
</p>
</body>
</html>
Output :
The border-style : The border-style property specifies what kind of border to display.
none : No border.
solid : Border is a single solid line.
dotted :Border is a series of dots.
dashed : Border is a series of short lines.
double : Border is two solid lines.
groove : Border looks as though it is carved into the page.
ridge : Border looks the opposite of groove.
inset : Border makes the box look like it is embedded in the page.
outset : Border makes the box look like it is coming out of the canvas.
hidden : Same as none, except in terms of border-conflict resolution for
table elements.
www.RNWMULTIMEDIA.com Page | 32
Example :
<html>
<body>
<p style="border-width:4px; border-style:none;">
This is a border with none width.
</p>
<p style="border-width:4px; border-style:solid;">
This is a solid border.
</p>
<p style="border-width:4px; border-style:dashed;">
This is a dashed border.
</p>
<p style="border-width:4px; border-style : double;">
This is a double border.
</p>
<p style="border-width:4px; border-style : groove;">
This is a groove border.
</p>
<p style="border-width:4px; border-style : ridge">
This is a ridge border.
</p>
<p style="border-width:4px; border-style : inset;">
This is a inset border.
</p>
<p style="border-width:4px; border-style : outset;">
This is a outset border.
</p>
<p style="border-width:4px; border-style : hidden;">
This is a hidden border.
</p>
<p style="border-width:4px;
border-top-style : solid;
border-bottom-style : dashed;
border-left-style : groove;
border-right-style : double; ">
This is a a border with four different styles.
</p>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 33
Output :
The border-width property allows you to set the width of an element borders.
The value of this property could be either a length in px, pt or cm or it should be
set to thin, medium or thick.
You can individually change the width of the bottom, top, left, and right borders
of an element using the following properties −
www.RNWMULTIMEDIA.com Page | 34
Example :
<html>
<body>
<p style="border-width:4px; border-style:solid;">
This is a solid border whose width is 4px.
</p>
<p style="border-width:4pt; border-style:solid;">
This is a solid border whose width is 4pt.
</p>
<p style="border-width:thin; border-style:solid;">
This is a solid border whose width is thin.
</p>
<p style="border-width:medium; border-style:solid;">
This is a solid border whose width is medium;
</p>
<p style="border-width:thick; border-style:solid;">
This is a solid border whose width is thick.
</p>
<p style="border-bottom-width:4px;
border-top-width:10px;
border-left-width:2px;
border-right-width:15px;
border-style:solid;">
This is a border with four different width.
</p>
</body>
</html>
Output :
www.RNWMULTIMEDIA.com Page | 35
The Rounded border :
Example :
<html>
<head>
<style>
p.n {
border: 2px solid red;
padding: 5px;
}
p.r1 {
border: 2px solid red;
border-radius: 5px;
padding: 5px;
}
p.r2 {
border: 2px solid red;
border-radius: 8px;
padding: 5px;
}
p.r3 {
border: 2px solid red;
border-radius: 12px;
padding: 5px;
}
</style>
</head>
<body>
<h2>The border-radius Property</h2>
<p>This property is used to add rounded borders to an element:</p>
Output :
www.RNWMULTIMEDIA.com Page | 36
4) CSS Margin :
Margins are used to create space around elements, outside of any defined borders.
We can set the different sizes of margins for individual sides(top, right, bottom,
left).
Property Description
margin This property is used to set all the properties in one declaration.
margin-left it is used to set left margin of an element.
margin-right It is used to set right margin of an element.
margin-top It is used to set top margin of an element.
margin-bottom It is used to set bottom margin of an element.
Value Description
o CSS shorthand property is used to shorten the code. It specifies all the margin
properties in one property.
o There are four types to specify the margin property. You can use one of them.
www.RNWMULTIMEDIA.com Page | 37
1. Example :
2.
3. <!DOCTYPE html>
4. <html>
5. <head>
6. <style>
7. p{
8. background-color: pink;
9. }
p.ex {
margin: 50px 100px 150px 200px;
}
</style>
</head>
<body>
<p>This paragraph is not displayed with specified margin. </p>
<p class="ex">This paragraph is displayed with specified margin.</p>
</body>
</html>
Output :
The CSS box model is a container that contains multiple properties including
borders, margin, padding, and the content itself.
It is used to create the design and layout of web pages.
It can be used as a toolkit for customizing the layout of different elements.
www.RNWMULTIMEDIA.com Page | 38
Explanation of the different parts:
Content : This property is used to displays the text, images, etc, that can be
sized using the width & height property.
Padding : This property is used to create space around the element, inside
any defined border.
Border : This property is used to cover the content & any padding, & also
allows to set the style, color, and width of the border.
Margin : This property is used to create space around the element.
Example :
<!DOCTYPE html>
<head>
<title>CSS Box Model</title>
<style>
.c1 {
margin-left: 60px;
border: 50px solid red;
width: 300px;
height: 200px;
text-align: center;
padding: 50px;
}
.c2 {
font-size: 42px;
font-weight: bold;
color: burlywood;
margin-top: 60px;
background-color: #2a2a5a;
}
.c3 {
font-size: 20px;
font-weight: bold;
background-color: #c5c5db;
}
</style>
</head>
<body>
<div><h1>CSS Box-Model Property</h1></div>
<div class="c1">
<div class="c2">Red & White college</div>
<div class="c3">
A computer IT Department
</div>
</div>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 39
6) CSS Text :
CSS text formatting properties is used to format text and style text.
Text-color Text-direction
Text-alignment Text-shadow
Text-decoration Letter spacing
Text-transformation Line height
Text-indentation Word spacing
Text-color :
Text-alignment :
o Text alignment property is used to set the horizontal alignment of the text.
o Text alignment property include value : left , center , right , justify
Example : Output :
<!DOCTYPE html>
<html> This is heading 1
<head>
<style> This is an ordinary paragraph.
body {
color: blue;
}
h1 {
color: green;
text-align: center;
}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<p>This is an ordinary paragraph. </p>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 40
Text-decoration :
Property Description
Example :
<html>
<head>
<style>
h1 {
text-decoration: overline;
text-decoration-color: red;
text-decoration-style: double;
text-decoration-thickness: 5px;
}
h3 {
text-decoration: underline red double 5px;
}
</style>
</head>
<body>
<h1>text decoration</h1>
<h2>text decoration</h2>
<h3>text decoration</h3>
<p><strong>Note:</strong> It is not recommended to underline text that is not a link, as this
often confuses
the reader.</p>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 41
Text-transformation :
Text-indentation :
o The text-indent property specifies the indentation of the first line in a text-block.
Example :
<!DOCTYPE html>
<html>
<head>
<style>
h2 {
text-transform: uppercase;
}
h3 {
text-transform: lowercase;
}
h4 {
text-transform: capitalize;
}
p{
text-indent: 50px;
}
</style>
</head>
<body>
<p>The text-indent property in CSS is used to define the indentation of the first line in each block
of text. It also take negative values. It means if the value is negative then the first line will be
indented to the left. length: It is used to set fixed indentation in terms of px, pt, cm, em etc.</p>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 42
Text-direction :
o The direction property specifies the text direction/writing direction within a block -
level element.(value : ltr , rtl).
Text-shadow :
Letter spacing :
o This property is used to specify the space between the characters of the text.
Line height :
Word spacing :
o Word spacing is used to specify the space between the words of the line.
Example :
<html>
<head>
<style>
</style>
</head>
<body>
</html>
www.RNWMULTIMEDIA.com Page | 43
7) CSS Fonts :
Property Description
CSS Font color This property is used to change the color of the text.
CSS Font family This property is used to change the face of the font.
CSS Font size This property is used to increase or decrease the size of the
font.
CSS Font style This property is used to make the font bold, italic or oblique.
CSS Font variant This property creates a small-caps effect.
CSS Font weight This property is used to increase or decrease the boldness and
lightness of the font.
o CSS font size property is used to change the size of the font.
www.RNWMULTIMEDIA.com Page | 44
CSS Font style :
o CSS Font style property defines what type of font you want to display.
o It may be italic, oblique, or normal.
o CSS font variant property specifies how to set font variant of an element.
o It may be normal and small-caps.
o CSS font weight property defines the weight of the font and specify that how
bold a font is.
o The possible values of font weight may be normal, bold or number (100,
200..... upto 900).
Example :
<html>
<head>
<style>
</style>
</head>
<body>
<h1>This heading is shown in sans-serif.</h1>
<h2>This heading is shown in serif.</h2>
<p>This paragraph is written in Times new roman.</p>
<h3>This heading is shown in normal font.</h3>
<p class="a">This paragraph is shown in small font.</p>
<p style="font-size:xx-small;"> This font size is extremely small.</p>
<p style="font-size:x-small;"> This font size is extra small</p>
<p style="font-size:small;"> This font size is small</p>
<p style="font-size:medium;"> This font size is medium. </p>
<p style="font-size:large;"> This font size is large. </p>
<p style="font-size:x-large;"> This font size is extra large. </p>
<p style="font-size:xx-large;"> This font size is extremely large. </p>
<p style="font-size:20px;"> This font size is 20 pixels. </p>
</body>
</html>
www.RNWMULTIMEDIA.com Page | 45