Web Programming: Introduction To Internet, HTML5 and CSS
Web Programming: Introduction To Internet, HTML5 and CSS
● The Web is just one of the ways that information can be disseminated over the Internet.
The Internet, not the Web, is also used for e-mail, which relies on SMTP, Usenet news
groups, instant messaging and FTP. So the Web is just a portion of the Internet, albeit a
large portion.
Uniform resource locator (URL)
● Abbreviation of Uniform Resource Locator (URL) it is the global address of
documents and other resources on the World Wide Web.
● The first part of the URL is called a protocol identifier and it indicates what protocol
to use, and the second part is called a resource name and it specifies the IP address or
the domain name where the resource is located. The protocol identifier and the resource
name are separated by a colon and two forward slashes.
● For example, Web page that should be fetched using the HTTP protocol:
● http://182.74.94.10:8080
Browsers
A web browser or Internet browser is a software application for retrieving,
presenting and traversing information resources on the world wide web.
An information resource is identified by a Uniform Resource Identifier(URI) and may
be a web page, image, video, or other piece of content.
A web browser can also be defined as an application software or program designed to
enable users to access, retrieve and view documents and other resources on the Internet.
Hyperlinks present in resources enable users to easily navigate their browsers to related
resources.
Although browsers are primarily intended to use the World Wide Web.
They can also be used to access information provided by web servers in private
networks or files in file systems.
The major web browsers are Chrome, Firefox, Internet Explorer, Opera, and Safari .
Browsers (Contd)
Internet explorer: Windows Internet Explorer (formerly called Microsoft Internet
Explorer, IE) is a series of graphical web browsers developed by Microsoft and included
as part of MS Windows line of operating systems starting in 1995. The latest stable
release is Internet Explorer 8, which is available as a free update for different versions of
Internet Explorer.
Netscape navigator: It is a proprietary web browser that was popular in the 1990’s. It
was the flagship product of the Netscape Communications Corporation.
Opera: It is the smallest and fastest browser in the world. It is offered free of charge for
personal computers and mobile phones. Its security features include built-in phishing
and malware protection, strong encryption when browsing secure websites.
Firefox: It is a popular, free, open-source web browser from Mozilla. Firefox is small
and fast. It is based on Mozilla code, and is one of the most standard compliant browsers
available.
Chrome: Google Chrome is a web browser developed by Google that uses the WebKit
Layout engine and application framework. It was first released as a beta version of
Microsoft Windows on 2nd September 2008 and public stable release was on 11 th
December 2008.
Search Engine
A program that searches documents for specified keywords and returns a list of
documents where the keywords were found.
A search engine works by sending out a spider to fetch as many documents as possible.
Another program, called as indexer, then reads these documents and creates an index
based on the words contained in each document.
Each search engine uses a proprietary algorithm to create its indices such that, only
meaningful results are returned for each query.
The World Wide Web is indexed through the use of search engines, which are also
referred to as ‘spiders’, ‘robots’, ‘crawlers’ or ‘worms’.
Some engines scan for information in the title or header of the document, while others
look at the bold headings on the page for their information.
Search Engine(Contd)
WebCrawler: Maintained by America Online, WebCrawler indexes over 2,00,000
pages on approximately 75,000 web servers. URLs, titles, and document content are
indexed.
Magellan: Magellan indexes over 80,000 websites. Search results are ranked and
annotated.
Lycos: It indexes over (1.5 million +) web page titles, headings, subheadings, URLs,
and significant text.
Yahoo: Yahoo has organized over 80,000 web sites into 14 broad categories. Yahoo also
maintains a comprehensive list of links to Yahoo – Computers and Internet: Internet;
World Wide Web: Searching the web other search engines, indexes and guides.
Web server –IIS(Internet Information
Services)
IIS (which stands for Internet Information Services or Internet Information
Server) also known as Windows web server is available on most versions of Microsoft
Windows operating systems and takes second place in overall usage behind Apache
HTTP Server on the internet.
It will host websites, web applications and services needed by users or developers.
An IIS web server accepts requests from remote client computers and returns the
appropriate response. This basic functionality allows web servers to share and
deliver information across local area networks (LAN), such as corporate intranets,
and wide area networks (WAN), such as the internet.
A web server can deliver information to users in several forms, such as static webpages
coded in HTML; through file exchanges as downloads and uploads; and text documents,
image files and more.
Web server - proxy server
Proxy Server
● In computer networks, a proxy server is a server (a computer system or an application)
that acts as an intermediary for requests from clients seeking resources from other
servers.
● It intercepts all requests to the real server to see if it can fulfill he requests itself. If not, it
forwards the request to the real server.
● A client connects to the proxy server, requesting some service, such as a file,
connection, web pages or other resource available from a different server and the
proxy server evaluates the request as a way to simplify and control their
complexity.
● It caches responses from the remote server, and returns subsequent requests for the same
content directly.
● Today most proxies are web proxies, facilitating access to content on the World Wide
Web.
Proxy server
HTTP Protocol
HTTP (Hypertext Transfer Protocol) is the set of rules/instructions for transferring
files (text, graphic images, sound, video, and other multimedia files) on the World
Wide Web.
The Hypertext Transfer Protocol is an application-level protocol for distributed,
collaborative, hypermedia information systems. This is the foundation for data
communication for the World Wide Web (i.e. internet).
HTTP is an application protocol that runs on top of the TCP/IP suite of protocols.
The communication between the client(your browser) and the server(a software located
on a remote computer) involves requests sent by the client and responses from the server.
Each client-server transaction, whether a request or a response, consists of three main
parts:
1. A response or request line
2. Header information
3. The body
HTTP Protocol
Hypertext is structured text that uses logical links (hyperlinks) between nodes containing
text. HTTP is the protocol to exchange or transfer hypertext.
HTTP functions as a request-response protocol in the client-server computing model.
HTTP is a stateless protocol. A stateless protocol does not require the HTTP server to
retain information or status about each user for the duration of multiple requests.
HTTP defines how messages are formatted and transmitted, and what actions Web
servers and browsers should take in response to various commands.
for example GET /images/logo.png HTTP/1.1
The other main standard that controls how the World Wide Web works is HTML, which
covers how Web pages are formatted and displayed.
HTTPS Short for Hypertext Transfer Protocol over Secure, HTTPS is a secure method
of accessing or sending information across a web page. All data sent over HTTPS is
encrypted before it is sent, this prevents anyone from understanding that information if
intercepted.
Unit 1
Chapter 2
HTML5: Introduction, Why HTML5? Formatting text by using tags, using lists
and backgrounds, Creating hyperlinks and anchors. Style sheets, CSS
formatting text using style sheets, formatting paragraphs using style sheets.
Introduction: What is HTML?
HTML stands for Hypertext Markup Language, and it is the most widely used language to write
Web Pages.
In simple terms, a Web page (or HTML document) is a plain text file that has been encoded using
Hypertext Markup Language (HTML) that tell a Web browser how to structure it to display.
Here’s what HTML means, word-by-word:
Hypertext
Text that you click to jump from document to document. This is a
reference to the ability of Web pages to link to one another. Eg: XYZ
HTML
Markup
Tags that apply layout and formatting conventions to plain text. Literally, the plain
text is “marked up” with the tags. Eg: <b>Hi</b>
Hi
Language
A reference to the fact that HTML is considered a programming language.
Why HTML5?
● It enables cleaner, easier-to-write code.
● HTML5 adds some important new tags to make audio, video, and application
integration smoother and more reliable by including <audio>, <video>, and
<canvas>.
● HTML5 removes support for some of the older tags. For example, an old way
(pre-HTML4) of specifying a font was the <font> tag. Today, most people use
cascading style sheets to define fonts, so the <font> tag has not been used by many
Web designers in a long time anyway. HTML5 formally removes it from the
language.
● One of the biggest things that HTML5 removes is the ability to create multi-
framed Web sites with the <frame> and <frameset> commands. You can still
create Web sites with multiple sections, but they’re handled much more capably
using tables or divisions.
Why HTML5?
Why HTML5?
JS
HTML Tags
● As told earlier, HTML is a markup language and makes use of various tags to format the
content. These tags are enclosed within angle braces <Tag Name>.
● Except few tags, most of the tags have their corresponding closing tags.
● For example, <html> has its closing tag</html> and <body> tag has its closing tag
</body> tag etc.
HTML Document Structure
Document declaration tag
<html>
<head>
Document header related tags
</head>
<body>
Document body related tags
</body>
</html>
HTML Document Structure
<!DOCTYPE html>
Basic Html Document: Demo.html
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
HTML Tags
The <!DOCTYPE> Declaration
● The <!DOCTYPE> declaration tag is used by the web browser to
understand the version of the HTML used in the document.
● There is only one <!DOCTYPE> declaration.
● Current version of HTML is 5 and it makes use of the following declaration:
● <!DOCTYPE html>
<!DOCTYPE html>
Formatting text by using tags
Paragraph Tag
● The HTML <p> element defines a paragraph.
● The <p> tag offers a way to structure your text into different paragraphs.
● A paragraph always starts on a new line, and browsers automatically add some white space (a
margin) before and after a paragraph.
● Each paragraph of text should go in between an opening <p> and a closing </p> tag.
Line Break Tag
● Whenever you use the <br /> element, anything following it starts from the next line. This tag is
an example of an empty element, where you do not need opening and closing tags, as there is
nothing to go in between them.
● The <br /> tag has a space between the characters br and the forward slash. If you omit this space,
older browsers will have trouble rendering the line break, while if you miss the forward slash
character and just use <br> it is not valid in XHTML(older version of HTML).
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.<br /> This is a line break </p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
Formatting text by using tags: Heading Tag
● HTML headings are titles or subtitles that you want to display on a webpage.
● Headings in Web pages function the same way as they do in printed documents—they
separate text into sections. The HTML standard defines six levels of headings, <h1>
through <h6>, each one progressively smaller in font size.
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
Formatting text by using tags
Element name Description
<b> This is a physical tag, which is used to bold the text written between it.
<strong> This is a logical tag, which tells the browser that the text is important.
<i> This is a physical tag which is used to make text italic.
<em> This is a logical tag which is used to display content in italic.
<mark> This tag is used to highlight text.
<u> This tag is used to underline text written between it.
<tt> This tag is used to appear a text in teletype. (not supported in HTML5) [Monospaced font]
<strike> This tag is used to draw a strikethrough on a section of text. (Not supported in HTML5)
<sup> It displays the content slightly above the normal line.
<sub> It displays the content slightly below the normal line.
<del> This tag is used to display the deleted content.
<ins> This tag displays the content which is added
<big> This tag is used to increase the font size by one conventional unit.
<small> This tag is used to decrease the font size by one unit from base font size.
Formatting text by using tags: Example
<!DOCTYPE html>
<html>
<head>
<title> Text and Block Formatting </title>
</head>
<body>
<p> <strong>This is a paragraph<strong></p>
This is <b> Bold text</b><br/>
This is <i> Italic text</i><br/>
This is <u> Underlined text</u><br/>
<ol> - An ordered list or numbered list. This will use different schemes of numbers to list
your items.
<dl> - A definition list or description list. This arranges your items in the same way as they
are arranged in a dictionary.
Lists
Ordered Lists
An Ordered list has each item numbered, this is useful to provide sequential instructions.
Ordered list is used extensively in formal documents.
The Ordered element < ol > encapsulates the complete list, and list element < li >
encapsulates each of list items.
The numbering starts at one and is incremented by one for each successive ordered list
element tagged with <li>.
Example:
<ol>
</ol>
Ordered Lists (Contd.) Lists
The type Attribute
Bulleted and numbered lists can be styled by using a list-style-type: type attribute.
You can use type attribute for <ol> tag to specify the type of numbering you like. By default,
it is a number. Following are the possible options −
<!DOCTYPE html>
<ol style="list-style-type: upper-roman"> <html>
<body>
<ol style="list-style-type: upper-roman">
<li>Macbook Air</li>
<li>iPhone</li>
<li>iPad</li>
<li>iMac</li>
</ol>
</body>
</html>
Ordered Lists (Contd.) Lists
The start Attribute
The start attribute specifies the start value of the first list item in an ordered list.
This value is always an integer, even when the numbering type is letters or romans. E.g., to
start counting list items from the letter "c" or the roman number "iii", use start="3".
<ol start="3">
Example: <ol start="number">
<li>Macbook Air</li>
<li>iPhone</li>
<li>iPad</li>
<li>iMac</li>
</ol>
Lists
Unordered Lists
Unordered list is similar to ordered list but the numerals are replaced with bullet points.
Unordered list is created within unordered tag <ul> and similar to ordered list, list items are
placed within list tag <li> .
Unordered list attribute " list-style-type" property can be used to replace bullet points with
disc, circular and square bullets.
Example:
<ul>
</ul>
Unordered Lists (Contd.)
Lists
The type Attribute
Bulleted and numbered lists can be styled by using a list-style-type: type attribute.
You can use type attribute for <ul> tag to specify the type of bullets you like. Following are
the possible options −
<ul style="list-style-type: square"> <!DOCTYPE html>
<html>
<body>
<ul style="list-style-type: circle">
<li>Macbook Air</li>
<li>iPhone</li>
<li>iPad</li>
<li>iMac</li>
</ul>
</body>
</html>
Nested Lists
Lists
Nested list is created by inserting a list within a list.The Sole idea behind this is to create a
sublist for a main list item .
The Sublist list is put inside the <li> element of the main list.
Example:
<body>
<ul>
<li>Linux</li>
<li>Windows
<ol>
<li>Windows 95.</li>
<li>Windows 98.</li>
<li>Windows XP.</li>
<li>Windows 7.</li>
</ol>
</li>
<li> Mac OS X</li>
</ul>
</body>
Lists
Definition Lists
HTML and XHTML supports a list style which is called definition lists where entries
are listed like in a dictionary or encyclopedia. The definition list is the ideal way to
present a glossary, list of terms, or other name/value list.
The Structure of definiton list is a term followed by its description or definition.
Its created with a Definition list tag <dl> encapsulating the complete list.
Within each <dl> tag you have a pair of definition term <dt> and definition description
element <dd>.
<dt> contains definition term, while <dd> contains the definition or description.
Example:
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Lists
Definition Lists
<!DOCTYPE html>
<html>
<body>
<dl>
<dt><b>HTML</b></dt>
<dd>This stands for Hyper Text Markup Language</dd>
<dt><b>HTTP</b></dt>
<dd>This stands for Hyper Text Transfer Protocol</dd>
<dt><b>TCP</b></dt>
</dl>
</body>
</html>
Using backgrounds: Specifying Colors
By default, your webpage background is white in color. HTML provides you following two
good ways to decorate your webpage background.
● HTML Background with Colors
● HTML Background with Images
Background Color
To specify a background color for an entire page, insert the
style=“background-color: color” attribute into the opening <body> tag. For example,
to make the background of an entire page yellow, use the following:
<body style="background-color: yellow">
You can use the color name, the RGB value, or the hexadecimal value. Therefore, the
following are equivalent to the code just shown:
<body style="background-color: #FFFF00">
<body style="background-color: rgb(255,255,0)">
Example:
<body style="background-image: url(nature.jpg)">
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
Using backgrounds: Specifying a Background
● The background-repeat property sets if/how a background image will be repeated.
● Image
By default, a background-image is repeated Fileand horizontally.
both vertically
● You can force it not to repeat by adding the background-repeat= attribute to the <body> tag and
specifying
repeat-x (repeat horizontally only), repeat-y (repeat vertically only), or no-repeat.
● For example, to prevent any repeating, use the following:
<body style="background-image: url(nature.jpg); background-color: beige; background-
repeat: no-repeat"> //If image is in same folder as code
<body style="background-image:url('C:/Users/Desktop/WEB PROGRAMMING/WP
PRACTICAL/nature.jpg'); background-repeat:no-repeat"> //If image is in other folder as code
● The background-attachment property sets whether a background image scrolls with the rest of the page, or
is fixed. By default, the background image scrolls with the text when the user scrolls down the page. To
force the image to stay fixed, add the background-attachment=fixed attribute to the <body> tag, as
follows:
<body style="background-image: url(granite.gif); background-color: beige;
background-attachment=fixed">
Note To avoid having to specify a path to the image file, place the image file and the
HTML file in the same folder.
Using backgrounds: Specifying a Background
● Example: Image File
repeat-x
(repeat horizontally only)
repeat-y
(repeat vertically only),
no-repeat.
Creating hyperlinks and anchors
● A link, or an anchor, is a word, a group of words or an image you can click to jump to
another document or a specific part of the current document.
● The Web is based on hyperlinks. Each Web page contains active links to other pages,
which in turn link to even more pages, until presumably the entire Web (or at least a great
chunk of it) is bound together.
● Paths that contain a complete address that anyone can use to get to that page are
called absolute paths. Absolute paths are very reliable.
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/css/default.asp">W3C</a></p>
<p><a href="https://www.google.com/">Google</a></p>
● In a relative path, the destination file is relative to the current file’s location. Relative
paths make it easier to develop and test your Web site in a different file location than the
one where it will eventually be stored.
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>
Hyperlinking: Setting the Target Window
HTML Links - The target Attribute
By default, the linked page will be displayed in the current browser window. To change this,
you must specify another target for the link.
The target attribute specifies where to open the linked document.
EXAMPLE:
<a href="https://www.XYZ.com/" target="_blank">Visit xyz!</a>
Hyperlinking to an email address
HTML Links – Link to an Email Address
mailto: is used inside the href attribute to create a link that opens the user's email program (to
let them send a new email):
EXAMPLE:
● To add a default subject line to the e-mail, add a ?subject= attribute after the e-mail
address, like this:
<a href="mailto:[email protected]?subject=Comment">Contact Us</a>
● The person using the hyperlink to contact you can change the subject line in her e-mail
program before sending the message.
Creating and Hyperlinking to Anchors
● An anchor is a marker within an HTML document, roughly analogous to a bookmark in
a Word document. You define a specific location in the document with an anchor name,
and then you can hyperlink directly to that anchor.
● Anchors are most valuable in long documents with multiple sections. They provide a
means for users to jump directly to whatever section they want rather than having to read or
scroll through the entire document.
● There are two parts to the process: you mark the anchor location, and then you create a
hyperlink that refers to it.
● To define an anchor, create an <a> tag around the destination text and include a name=
attribute. For example, suppose you have a heading that reads Conclusion, and you want
to create an anchor point with that same name:
<a name="conclusion">Conclusion</a>
Creating and Hyperlinking to Anchors
● An anchor is a marker within an HTML document, roughly analogous to a bookmark in
a Word document. You define a specific location in the document with an anchor name,
and then you can hyperlink directly to that anchor.
● Anchors are most valuable in long documents with multiple sections. They provide a
means for users to jump directly to whatever section they want rather than having to read or
scroll through the entire document.
● There are two parts to the process: you mark the anchor location, and then you create a
hyperlink that refers to it.
● To define an anchor, create an <a> tag around the destination text and include a name=
attribute. For example, suppose you have a heading that reads Conclusion, and you want
to create an anchor point with that same name:
<a name="conclusion">Conclusion</a>
Creating and Hyperlinking to Anchors
● To refer to the anchor point, include its name in the href= attribute. Precede the anchor
name with a pound sign (#). If the anchor point is in the same document as the hyperlink, you can
use a relative reference like this:
○ <a href="#conclusion">View the Conclusion</a>
● Otherwise, you must include the name of the file in which the anchor is located. For
example, if the anchor were in a file called report.htm, it would look like this:
○ <a href="report.html#conclusion">View the Conclusion</a>
● The same rules apply to the file name as they do with regular hyperlinks. If the document
is not in the same folder, you must refer to the folder either absolutely or relatively.
Style sheets
● Cascading Style Sheets (CSS) describe how documents are presented on screens, in
print, or perhaps how they are pronounced. W3C has actively promoted the use of style
sheets on the Web since the Consortium was founded in 1994.
● Cascading Style Sheet(CSS) is used to set the style in web pages that contain HTML
elements. It sets the background-color, font-size, font-family, color, … etc. property of
elements on a web page.
● CSS is used to define styles for your web pages, including the design, layout and
variations in display for different devices and screen sizes.
● Each property has a name and a value, separated by a colon (:). Each property
declaration is separated by a semi-colon (;).
Style sheets
Disadvantage:
1. Time Consuming
2. Extra efforts for each tag
Cascading Style sheets Syntax
Cascading Style sheets Syntax
• The selector points to the HTML element you want to style.
• The declaration block contains one or more declarations separated by semicolons.
• 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:
<style>
p{
color: red;
text-align: center;
}
</style>
Types of CSS: 2. Internal or Embedded Style
• The internal style sheet is used to add a unique style for a single document. It is defined in
<head> section of the HTML page inside sheets
the <style> tag.
• Internal CSS is used in the condition when we want a style to be used in the complete HTML
body.
Example: <!DOCTYPE html>
<html>
<head>
<style>
<style>
p{
p{
color: red;
color: red;
text-align: center;
text-align: center;
}
}
</style>
</style>
</head>
<body>
<p>Hello World!</p>
<p>These paragraphs are styled with CSS.</p>
</body>
</html>
Types of CSS: 3. External Style sheets
● The external style sheet is generally used when you want to make changes on multiple
pages. It is ideal for this condition because it facilitates you to change the look of the
entire web site by changing just one file.
● External CSS contains separate CSS file which contains only style property with
the help of tag attributes (For example class, id, heading, … etc).
● CSS property written in a separate file with .css extension and should be linked to the
HTML document using link tag. This means that for each element, style can be set
only once and that will be applied across web pages.
● It uses the <link> tag on every pages and the <link> tag should be put inside the
head section.
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
The required rel attribute specifies the relationship between the current document and the
linked document/resource.
Types of CSS: 3. External Style sheets
Style.css Cssdemo.html
p <html>
{ <head>
font-family:Times new roman; <title>CSS</title>
font-size:20px;
<link rel="stylesheet" type="text/css" href="style.css">
text-transform:uppercase;
color:white; </head>
background-color:green; <body >
} <p>Welcome FYIT......<br>A very Good Morning<br>
body This is Practical No:08 <br> We are going to study
{ CSS...<br>CSS<br>stands for<br>Cascading Style Sheet
background-color:red; <br>This is an interesting concept<br>Let's start coding</p>
background-image:url("Sunset.jpg");
<p>
}
You have to dream before your dreams can come true.
</p>
<h1>Have a good day</h1>
</body>
Types of CSS: 3. External Style sheets
CSS formatting text using style sheets
CSS formatting text using style sheets
● CSS has a lot of properties for formatting text.
● The commonly used text properties are: text-align, text-decoration, text-transform, text-
indent, line-height, letter-spacing, word-spacing, and more. These properties give you
precise control over the visual appearance of the characters, words, spaces, and so on.
Property Description
color Text Color: The color of the text is defined by the CSS color property.
text-align Text Alignment: The text-align property is used to set the horizontal alignment of the text.
Text can be aligned in four ways: to the left, right, centre or justified (straight left and right
margins).
text-decoration Text Decoration: The text-decoration property is used to set or remove decorations from text.
This property typically accepts one of the following values: underline, overline, line-through,
and none. You should avoid underline text that is not a link, as it might confuse the visitor.
text-transform Text Transformation: The text-transform property is used to set the cases for a text.
Text are often written in mixed case. However, in certain situations you may want to display your
text in entirely different case. Using this property you can change an element's text content into
uppercase or lowercase letters, or capitalize the first letter of each word without modifying the
original text.
CSS formatting text using style sheets: Fonts
Property Description
font-family The font-family property is used to specify the font to be used to render the text. This property can hold
several comma-separated font names as a fallback system, so that if the first font is not available on the
user's system, browser tries to use the second one, and so on.
List with a generic font family which are five — serif, sans-serif, monospace, cursive and fantasy.
font-style The font-style property is used to set the font face style for the text content of an element.
The font style can be normal, italic or oblique. The default value is normal.
font-size The font-size property is used to set the size of font for the text content of an element. There are several
ways to specify the font size values e.g. with keywords, percentage, pixels, etc.
font-weight The font-weight property specifies the weight or boldness of the font.
This property can take one of the following values: normal, bold, bolder, lighter, 100, 200, 300, 400, 500,
600, 700, 800, 900 and inherit.
font-variant The font-variant property allows the text to be displayed in a special small-caps variation.
Small-caps or small capital letters are slightly different to normal capital letters, in which lowercase letters
appear as smaller versions of the corresponding uppercase letters.
CSS formatting text using style sheets
<!DOCTYPE html>
<html>
<head>
<title>Setting font-style in CSS</title>
</head>
<body style="font-family: Sans-serif, Arial, Helvetica; ">
<p style="font-style: normal; font-size=30px;font-weight: bold; font-variant: small-caps;">
This is a normal paragraph.</p>
<h1 style="font-style: italic; font-size: xx-large;">This is a paragraph with italic font style.</h1>
<h2 style="font-style: oblique; font-size=60px;">This is a paragraph with oblique font
style</h2>
</body>
</html>
Formatting paragraphs using style sheets
Property Description
border-style The border-style property sets the style of a box's border such as: solid, dotted, etc. It is a shorthand
property for setting the line style for all four sides of the elements border.
The border-style property can have the following values: none, hidden, solid, dashed, dotted,
double, inset, outset, groove, and ridge.
border-width Setting the Border Width: The border-width property specifies the width of the border area. It is a
shorthand property for setting the thickness of all the four sides of an element's border at the same time.
border-color Specifying the Border Color: The border-color property specifies the color of the border area. This is
also a shorthand property for setting the color of all the four sides of an element's border.
padding Setting Border Padding: The CSS padding properties allow you to set the spacing between the content
of an element and its border (or the edge of the element's box, if it has no defined border).
p { border-style: solid; }
OR
<p style=“border-style: solid; border-width:30px; border-color: black; padding: 30px;”>DONE</p>
Formatting paragraphs using style sheets
CSS formatting text using style sheets: Fonts
Property Description
text-indent Text Indentation
The text-indent property is used to set the indentation of the first line of text within a block of text. It
is typically done by inserting the empty space before the first line of text.
The size of the indentation can be specified using percentage (%), length values in pixels, etc.
letter- Letter Spacing
spacing The letter-spacing property is used to set extra spacing between the characters of text.
This property can take a length value in pixels, ems, etc. It may also accept negative values. When
setting letter spacing, a length value indicates spacing in addition to the default inter-character space.
line-height Line Height (VERTICAL HEIGHT)
The line-height property is used to set the height of the text line.
It is also called leading and commonly used to set the distance between lines of text.
The value of this property can be a number, a percentage (%), or a length in pixels, etc.
border The Border Shorthand Property
The border CSS property is a shorthand property for setting one or more of the individual border
properties border-width, border-style and border-color in a single rule.
p{
border: 5px solid #00ff00;
}
CSS formatting
<!DOCTYPE html>
text using style sheets
p
<html> {
<head> width: 300px;
<title>Setting Text Alignment using text-align: justify;
CSS</title> text-decoration:line-through;
text-transform: lowercase;
<style> text-indent:50px;
h1 line-height: 1.2;
{ word-spacing:140px;
color:lightgreen; }
text-align: center; </style>
text-decoration:overline; </head>
text-transform: uppercase; <body>
letter-spacing: 40px; <h1>This is a heading</h1>
<p> Where there is a will, there is a way. Try and
} try till you succeed. Good Luck!!! Shine and Smile,
fill the world with your positive radiations</p>
</body>
</html>
h1
CSS formatting text and paragraphs using
{ style sheets
color:lightgreen;
text-align: center;
text-decoration:overline;
text-transform: uppercase;
letter-spacing: 40px;
border: 5px solid #00ff00;
}
p
{
width: 300px;
text-align: justify;
text-decoration:line-through;
text-transform: lowercase;
text-indent:50px;
line-height: 1.2;
word-spacing:140px;