Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

CSS

CSS, or Cascading Style Sheets, is a design language used to enhance the presentation of web pages by controlling elements like color, layout, and device compatibility. It offers advantages such as time-saving, faster loading, easy maintenance, and a wider range of styling options compared to HTML. CSS has evolved through various versions, with CSS3 introducing modules that expand its capabilities, and it can be included in HTML documents through inline, embedded, or external methods.

Uploaded by

2005vinayraj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CSS

CSS, or Cascading Style Sheets, is a design language used to enhance the presentation of web pages by controlling elements like color, layout, and device compatibility. It offers advantages such as time-saving, faster loading, easy maintenance, and a wider range of styling options compared to HTML. CSS has evolved through various versions, with CSS3 introducing modules that expand its capabilities, and it can be included in HTML documents through inline, embedded, or external methods.

Uploaded by

2005vinayraj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 49

CSS - QUICK GUIDE

WHAT IS CSS?
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended
to simplify the process of making web pages presentable.

CSS handles the look and feel part of a web page. Using CSS, you can control the color
of the text, the style of fonts, the spacing between paragraphs, how columns are sized
and laid out, what background images or colors are used, layout designs,variations in
display for different devices and screen sizes as well as a variety of other effects.

CSS is easy to learn and understand but it provides powerful control over the
presentation of an HTML document. Most commonly, CSS is combined with the markup
languages HTML or XHTML.

Advantages of CSS
CSS saves time − You can write CSS once and then reuse same sheet in
multiple HTML pages. You can define a style for each HTML element and apply it
to as many Web pages as you want.

Pages load faster − If you are using CSS, you do not need to write HTML tag
attributes every time. Just write one CSS rule of a tag and apply it to all the
occurrences of that tag. So less code means faster download times.

Easy maintenance − To make a global change, simply change the style, and all
elements in all the web pages will be updated automatically.

Superior styles to HTML − CSS has a much wider array of attributes than
HTML, so you can give a far better look to your HTML page in comparison to
HTML attributes.

Multiple Device Compatibility − Style sheets allow content to be optimized


for more than one type of device. By using the same HTML document, different
versions of a website can be presented for handheld devices such as PDAs and
cell phones or for printing.

Global web standards − Now HTML attributes are being deprecated and it is
being recommended to use CSS. So its a good idea to start using CSS in all the
HTML pages to make them compatible to future browsers.

Offline Browsing − CSS can store web applications locally with the help of an
offline catche.Using of this, we can view offline websites.The cache also ensures
faster loading and better overall performance of the website.

Platform Independence − The Script offer consistent platform independence


and can support latest browsers as well.

Who Creates and Maintains CSS?


CSS was invited by Håkon Wium Lie on October 10, 1994 and maintained through a
group of people within the W3C called the CSS Working Group. The CSS Working Group
creates documents called specifications. When a specification has been discussed and
officially ratified by W3C members, it becomes a recommendation.

These ratified specifications are called recommendations because the W3C has no
control over the actual implementation of the language. Independent companies and
organizations create that software.

NOTE − The World Wide Web Consortium, or W3C is a group that makes
recommendations about how the Internet works and how it should evolve.

CSS Versions
Cascading Style Sheets, level 1 CSS1 was came out of W3C as a recommendation in
December
1996. This version describes the CSS language as well as a simple visual formatting
model for all the HTML tags.

CSS2 was became a W3C recommendation in May 1998 and builds on CSS1. This
version adds support for media-specific style sheets e.g. printers and aural devices,
downloadable fonts, element positioning and tables.

CSS3 was became a W3C recommendation in June 1999 and builds on older versions
CSS. it has divided into documentations is called as Modules and here each module
having new extension features defined in CSS2.

CSS3 Modules
CSS3 Modules are having old CSS specifications as well as extension features.

Selectors
Box
Model
Backgrounds and Borders
Image Values and Replaced
Content Text Effects
2D/3D
Transformations
Animations
Multiple Column
Layout User Interface

CSS - SYNTAX
A CSS comprises of style rules that are interpreted by the browser and then applied to the
corresponding elements in your document. A style rule is made of three parts −

Selector − A selector is an HTML tag at which a style will be applied. This could
be any tag like <h1> or <table> etc.

Property - A property is a type of attribute of HTML tag. Put simply, all the HTML
attributes are converted into CSS properties. They could be color, border etc.

Value - Values are assigned to properties. For example, color property can have
value either
red or #F1F1F1 etc.

You can put CSS Style Rule Syntax as follows −

selector { property: value }

Example: You can define a table border as follows −


table{ border :1px solid #C00; }
Here table is a selector and border is a property and given value 1px solid #C00 is
the value of that property.

You can define selectors in various simple ways based on your comfort. Let me put
these selectors one by one.

The Type Selectors


This is the same selector we have seen above. Again, one more example to give a color
to all level 1 headings:

h1 {
color: #36CFFF;
}

The Universal Selectors


Rather than selecting elements of a specific type, the universal selector quite simply
matches the name of any element type −

* {
color: #000000;
}

This rule renders the content of every element in our document in black.

The Descendant Selectors


Suppose you want to apply a style rule to a particular element only when it lies inside a
particular element. As given in the following example, style rule will apply to <em>
element only when it lies inside <ul> tag.

ul em {
color: #000000;
}

The Class Selectors


You can define style rules based on the class attribute of the elements. All the elements
having that class will be formatted according to the defined rule.

.black {
color: #000000;
}

This rule renders the content in black for every element with class attribute set to black in
our document. You can make it a bit more particular. For example:

h1.black {
color: #000000;
}

This rule renders the content in black for only <h1> elements with class attribute set

to black. You can apply more than one class selectors to given element. Consider the

following example:

<p >
This para will be styled by the classes center and bold.
</p>

The ID Selectors
You can define style rules based on the id attribute of the elements. All the elements
having that id
will be formatted according to the defined rule.

#black {
color: #000000;
}

This rule renders the content in black for every element with id attribute set to black in
our document. You can make it a bit more particular. For example −

h1#black {
color: #000000;
}

This rule renders the content in black for only <h1> elements with id attribute set to
black.

The true power of id selectors is when they are used as the foundation for descendant
selectors, For example:

#black h2 {
color: #000000;
}

In this example all level 2 headings will be displayed in black color when those headings
will lie with in tags having id attribute set to black.

The Child Selectors


You have seen the descendant selectors. There is one more type of selector, which is
very similar to descendants but have different functionality. Consider the following
example −

body > p {
color: #000000;
}

This rule will render all the paragraphs in black if they are direct child of <body> element.
Other paragraphs put inside other elements like <div> or <td> would not have any
effect of this rule.

The Attribute Selectors


You can also apply styles to HTML elements with particular attributes. The style rule
below will match all the input elements having a type attribute with a value of text −

input[type = "text"]{
color: #000000;
}

The advantage to this method is that the <input type = "submit" /> element is unaffected,
and the color applied only to the desired text fields.

There are following rules applied to attribute selector.

p[lang] − Selects all paragraph elements with a lang attribute.

p[lang="fr"] − Selects all paragraph elements whose lang attribute has a


value of exactly "fr".

p[lang~="fr"] − Selects all paragraph elements whose lang attribute contains


the word "fr".

p[lang|="en"] − Selects all paragraph elements whose lang attribute contains


values that are exactly "en", or begin with "en-".
Multiple Style Rules
You may need to define multiple style rules for a single element. You can define these
rules to
combine multiple properties and corresponding values into a single block as defined in
the following example −

h1 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}

Here all the property and value pairs are separated by a semi colon ; . You can keep
them in a single line or multiple lines. For better readability we keep them into separate
lines.

For a while, don't bother about the properties mentioned in the above block. These
properties will be explained in the coming chapters and you can find complete detail
about properties in CSS References.

Grouping Selectors
You can apply a style to many selectors if you like. Just separate the selectors with a
comma, as given in the following example −

h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}

This define style rule will be applicable to h1, h2 and h3 element as well. The order of
the list is irrelevant. All the elements in the selector will have the corresponding
declarations applied to them.

You can combine the various class selectors together as shown below −

#content, #footer, #supplement {


position: absolute;
left: 510px;
width: 200px;
}

CSS - INCLUSION
There are four ways to associate styles with your HTML document. Most commonly used
methods are inline CSS and External CSS.

Embedded CSS - The <style> Element


You can put your CSS rules into an HTML document using the <style> element. This
tag is placed inside <head>...</head> tags. Rules defined using this syntax will be
applied to all the elements available in the document. Here is the generic syntax −

Following is the example of embed CSS based on the above syntax −

<!DOCTYPE html>
<html>
<head>
<style type = "text/css" media = "all">
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>

It will produce the following result −


Attributes

Attributes associated with <style> elements are −

Attribut Value Description


e
Type text/css Specifies the style sheet language as a content-type MIMEtype.
This is required attribute.

medi
a screen

tty

tv

projectio
Specifies the device the document will be displayed on. Default
n
value is all. This is an optional attribute.
handheld

print

braille

aural

all

Inline CSS - The style Attribute


You can use style attribute of any HTML element to define style rules. These rules will be
applied to that element only. Here is the generic syntax −

<element style = "...style rules.........">

Attributes

Attribute Value Description


style style rules The value of style attribute is a combination of style
declarations separated by semicolon ; .

Example
Following is the example of inline CSS based on the above syntax −

<html>
<head>
</head>
<body>
<h1 style = "color:#36C;"> This is inline CSS </h1>
</body>
</html>

External CSS - The <link> Element


The <link> element can be used to include an external stylesheet file in your HTML
document.

An external style sheet is a separate text file with .css extension. You define all the
Style rules within this text file and then you can include this file in any HTML document
using <link> element.

Here is the generic syntax of including external CSS file −

<head>
<link type = "text/css" href = "..." media = "..." />
</head>

Attributes
Attributes associated with <style> elements are −

Attribut Value Description


e
Type text/css Specifies the style sheet language as a content-type MIMEtype.
This attribute is required.

Href URL Specifies the style sheet file having Style rules. This attribute is a
required.

medi
a screen

tty

tv

projection
Specifies the device the document will be displayed on. Default
handhel
value is all. This is optional attribute.
d
print

braille

aural

all

Example
Consider a simple style sheet file with a name mystyle.css having the following rules −

h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}

Now you can include this file mystyle.css in any HTML document as follows −

<head>
<link type = "text/css" href = "mystyle.css" media = " all" />
</head>

Imported CSS - @import Rule


@import is used to import an external stylesheet in a manner similar to the <link>
element. Here is the generic syntax of @import rule.

<head>
<@ import "URL";
</head>

Here URL is the URL of the style sheet file having style rules. You can use another syntax
as well −

<head>
<@ import url("URL");
</head>

Example
Following is the example showing you how to import a style sheet file into HTML document

<head>
@ import "mystyle.css";
</head>

CSS Rules Overriding


We have discussed four ways to include style sheet rules in a an HTML document. Here
is the rule to override any Style Sheet Rule.

Any inline style sheet takes highest priority. So, it will override any rule defined in
<style>...</style> tags or rules defined in any external style sheet file.

Any rule defined in <style>...</style> tags will override rules defined in any
external style sheet file.
Any rule defined in external style sheet file takes lowest priority, and rules defined in
this file
will be applied only when above two rules are not applicable.

Handling old Browsers


There are still many old browsers who do not support CSS. So, we should take care
while writing our Embedded CSS in an HTML document. The following snippet shows
how you can use comment tags to hide CSS from older browsers −

<style type="text/css">
<!--
body, td {
color: blue;
}
-->
</style>

CSS Comments
Many times, you may need to put additional comments in your style sheet blocks. So, it is
very easy to comment any part in style sheet. You can simple put your comments
inside /*...................................................................................................................................................this is a
comment in style sheet */.

You can use /*. */ to comment multi-line blocks in similar way you do in C and C++
programming
languages.

Example

<!DOCTYPE html>
<html>
<head>
<style>
p {
color: red;
/* This is a single-line comment */
text-align: center;
}
/* This is a multi-line comment */
</style>
</head>
<body>
<p>Hello World!</p>
</body>
</html>

CSS - MEASUREMENT UNITS


Before we start actual exercise, we would like to give a brief idea about the CSS
Measurement Units.

CSS supports a number of measurements including absolute units such as inches,


centimeters, points, and so on, as well as relative measures such as percentages and
em units. You need these values while specifying various measurements in your Style
rules e.g border = "1px solid red".
We have listed out all the CSS Measurement Units along with proper Examples −

Unit Description Example

% Defines a measurement as a percentage relative to p {font-size:


another value, typically an enclosing element. 16pt; line-height:
125%;}

cm Defines a measurement in centimeters. div {margin-


bottom:
2cm;}

em A relative measurement for the height of a font in em p {letter-spacing:


spaces. Because an em unit is equivalent to the size of 7em;}
a given font, if you assign a font to 12pt, each "em"
unit would be 12pt; thus, 2em would be 24pt.

ex This value defines a measurement relative to a font's x- p {font-size:


height. The x-height is determined by the height of the 24pt; line-
font's lowercase letter x. height: 3ex;}

in Defines a measurement in inches. p {word-spacing:


.15in;}

mm Defines a measurement in millimeters. p {word-


spacing:
15mm;}

pc Defines a measurement in picas. A pica is equivalent p {font-size: 20pc;}


to 12 points; thus, there are 6 picas per inch.

pt Defines a measurement in points. A point is defined as body {font-size:


1/72nd of an inch. 18pt;}

px Defines a measurement in screen pixels. p {padding: 25px;}

vh 1% of viewport height. h2 { font-


size: 3.0vh;
}

vw 1% of viewport width h1 { font-size:


5.9vw; }

vmin 1vw or 1vh, whichever is smaller p { font-


size:
2vmin;}

CSS - COLORS
CSS uses color values to specify a color. Typically, these are used to set a color either
for the foreground of an element i. e. , itstext or else for the background of the element.
They can also be used to affect the color of borders and other decorative effects.

You can specify your color values in various formats. Following table lists all the possible
formats −

Format Syntax Example

Hex Code #RRGGBB p{color:#FF0000;


}
Short Hex #RGB p{color:#6A7;}
Code
RGB % rgbrrr p{color:rgb50;}

RGB Absolute rgbrrr, ggg, bbb p{color:rgb0, 0,


255;}
keyword aqua, black, etc. p{color:teal;}
These formats are explained in more detail in the following sections −

CSS Colors - Hex Codes


A hexadecimal is a 6 digit representation of a color. The first two digitsRR represent a
red value, the next two are a green valueGG, and the last are the blue valueBB.

A hexadecimal value can be taken from any graphics software like Adobe Photoshop,
Jasc Paintshop Pro, or even using Advanced Paint Brush.

Each hexadecimal code will be preceded by a pound or hash sign '#'. Following are
the examples to use Hexadecimal notation.

Colo Color
r HEX
#0000

00

#FF000

#00FF0

#0000F

#FFFF0
#FFFFFF

CSS Colors - Short Hex Codes


This is a shorter form of the six-digit notation. In this format, each digit is replicated to
arrive at an equivalent six-digit value. For example: #6A7 becomes #66AA77.

A hexadecimal value can be taken from any graphics software like Adobe Photoshop,
Jasc Paintshop Pro, or even using Advanced Paint Brush.

Each hexadecimal code will be preceded by a pound or hash sign '#'. Following are
the examples to use Hexadecimal notation.

Colo Color
r HEX
#00

#F0

#0F

#0F

F
#FFF
CSS Colors - RGB Values
This color value is specified using the rgb property. This property takes three values,
one each for red, green, and blue. The value can be an integer between 0 and 255 or a
percentage.

NOTE: All the browsers does not support rgb property of color so it is recommended not to

use it. Following is the example to show few colors using RGB values.

Colo Color
r RGB
rgb0, 0, 0

rgb255, 0, 0

rgb0, 255, 0

rgb0, 0, 255

rgb255, 255, 0

rgb0, 255, 255

rgb255, 0, 255

rgb192, 192,

rgb255, 255, 255


192

Browser Safe Colors


Here is the list of 216 colors which are supposed to be most safe and computer
independent colors. These colors vary from hexa code 000000 to FFFFFF. These colors
are safe to use because they ensure that all computers would display the colors correctly
when running a 256 color palette

000000 000033 000066 000099 0000CC 0000FF

003300 003333 003366 003399 0033CC 0033FF

006600 006633 006666 006699 0066CC 0066FF

009900 009933 009966 009999 0099CC 0099FF

00CC00 00CC33 00CC66 00CC99 00CCC 00CCF


C F
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF

330000 330033 330066 330099 3300CC 3300FF

333300 333333 333366 333399 3333CC 3333FF

336600 336633 336666 336699 3366CC 3366FF

339900 339933 339966 339999 3399CC 3399FF

33CC00 33CC33 33CC66 33CC99 33CCC 33CCF


C F
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF

663300 663333 663366 663399 6633CC 6633FF

666600 666633 666666 666699 6666CC 6666FF

669900 669933 669966 669999 6699CC 6699FF

66CC00 66CC33 66CC66 66CC99 66CCC 66CCF


C F
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF

990000 990033 990066 990099 9900CC 9900FF

993300 993333 993366 993399 9933CC 9933FF

996600 996633 996666 996699 9966CC 9966FF

999900 999933 999966 999999 9999CC 9999FF

99CC00 99CC33 99CC66 99CC99 99CCC 99CCF


C F
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF

CC0000 CC0033 CC0066 CC0099 CC00C CC00F


C F
CC3300 CC3333 CC3366 CC3399 CC33C CC33F
C F
CC6600 CC6633 CC6666 CC6699 CC66C CC66F
C F
CC9900 CC9933 CC9966 CC9999 CC99C CC99F
C F
CCCC00 CCCC33 CCCC66 CCCC99 CCCCC CCCCFF
C
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF

FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF

FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF

FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF

FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF

FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF

FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF

CSS - BACKGROUND
This chapter teaches you how to set backgrounds of various HTML elements. You can
set the following background properties of an element −

The background-color property is used to set the background color of an


element.

The background-image property is used to set the background image of an


element.

The background-repeat property is used to control the repetition of an image in the


background.

The background-position property is used to control the position of an image in


the background.

The background-attachment property is used to control the scrolling of an image


in the background.
The background property is used as a shorthand to specify a number of other
background properties.

Set the Background Color


Following is the example which demonstrates how to set the background color for an
element.

<html>
<head>
<body>
<p style = " background-color:yellow;" >
This text has a yellow background color.</p>
</body>
</head>
<html>

Set the Background Image


We can set the background image by calling local storaged images as shown below

<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-color: #cccccc;
}
</style>
<body>
<h1>Hello World!</h1>
</body>
</head>
<html>

Repeat the Background Image


The following example demonstrates how to repeat the background image if an image
is small. You can use no-repeat value for background-repeat property if you don't want to
repeat an image, in this case image will display only once.

By default background-repeat property will have repeat value.

<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-repeat: repeat;
}
</style>
</head>
<body>
<p>Tutorials point</p>
</body>
</html>

The following example which demonstrates how to repeat the background image
vertically.

<html>
<head>
<style>
The following example demonstrates how to repeat the background image horizontally.
</style>
<html>
</head>
<head>
<body>
<style>
<p>Tutorials point</>
body {
</body>
background-image: url("/css/images/css.jpg");
</html>
background-repeat: repeat-x;
}

Set the Background Image Position


The following example demonstrates how to set the background image position 100
pixels away from the left side.

<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-position:100px;
}
</style>
</head>
<body>
<p>Tutorials point</>
</body>
</html>

The following example demonstrates how to set the background image position 100
pixels away from the left side and 200 pixels down from the top.
</html>
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-position:100px 200px;
}
</style>
</head>
<body>
<p>Tutorials point</>
</body>

Set the Background Attachment

Background attachment determines whether a background image is fixed or scrolls with


the rest of the page.

The following example demonstrates how to set the fixed background image.
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('/css/images/css.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
</head>
<body>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
</body>
</html>

The following example demonstrates how to set the scrolling background image.

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('/css/images/css.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-attachment:scroll;
}.
</style>
</head>
<body>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
<p>;The background-image is fixed. Try to scroll down the page.</p>
</body>
</html>

Shorthand Property
You can use the background property to set all the background properties at once. For
example −

<p style=" background:url(/images/pattern1.gif) repeat fixed;"


> This parapgraph has fixed repeated background image.
</p>

CSS - FONTS
This chapter teaches you how to set fonts of a content, available in an HTML element. You
can set following font properties of an element −

The font-family property is used to change the face of a font.

The font-style property is used to make a font italic or

oblique. The font-variant property is used to create a

small-caps effect.

The font-weight property is used to increase or decrease how bold or light a

font appears. The font-size property is used to increase or decrease the size of a

font.

The font property is used as shorthand to specify a number of other font properties.

Set the Font Family


Following is the example, which demonstrates how to set the font family of an element.
Possible value could be any font family name.

<html>
<head>
</head>
<body>
<p style=" font-family:georgia,garamond,serif;" >
This text is rendered in either georgia, garamond, or the default serif font
depending on which font you have at your system.
</p>
</body>
</html>

Set the Font Style


Following is the example, which demonstrates how to set the font style of an element.
Possible values are normal, italic and oblique.

<html>
<head>
</head>
<body>
<p style=" font-style:italic;" >
This text will be rendered in italic style
</p>
</body>
</html>

Set the Font Variant


The following example demonstrates how to set the font variant of an element. Possible
values are
normal and small-caps.

<html>
<head>
</head>
<body>
<p style=" font-variant:small-caps;" >
This text will be rendered as small caps
</p>
</body>
</html>

Set the Font Weight


The following example demonstrates how to set the font weight of an element. The font-
weight property provides the functionality to specify how bold a font is. Possible values
could be normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900.

<html>
<head>
</head>
<body>
<p style=" font-weight:bold;" >This font is bold.</p>
<p style=" font-weight:bolder;" >This font is bolder.</p>
<p style=" font-weight:500;" >This font is 500 weight.</p>
</body>
</html>

Set the Font Size


The following example demonstrates how to set the font size of an element. The font-size
property is used to control the size of fonts. Possible values could be xx-small, x-small,
small, medium, large, x-large, xx-large, smaller, larger, size in pixels or in %.
<html>
<head>
</head>
<body>
<p style=" font-size:20px;" >This font size is 20 pixels</p>
<p style=" font-size:small;" >This font size is small</p>
<p style=" font-size:large;" >This font size is large</p>
</body>
</html>

Set the Font Size Adjust


The following example demonstrates how to set the font size adjust of an element. This
property enables you to adjust the x-height to make fonts more legible. Possible value
could be any number.

<html>
<head>
</head>
<body>
<p style=" font-size-adjust:0.61;" >
This text is using a font-size-adjust value.
</p>
</body>
</html>

Set the Font Stretch


The following example demonstrates how to set the font stretch of an element. This
property relies on the user's computer to have an expanded or condensed version of
the font being used.

Possible values could be normal, wider, narrower, ultra-condensed, extra-condensed,


condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-
expanded.

<html>
<head>
</head>
<body>
<p style=" font-stretch:ultra-expanded;" >
If this doesn't appear to work, it is likely that your computer doesn't have a
condensed or expanded version of the font being used.
</p>
</body>
</html>

Shorthand Property
You can use the font property to set all the font properties at once. For example −

<html>
<head>
</head>
<body>
<p style=" font:italic small-caps bold 15px georgia;" >
Applying all the properties on the text at once.
</p>
</body>
</html>
CSS - TEXT
This chapter teaches you how to manipulate text using CSS properties. You can set
following text properties of an element −

The color property is used to set the color of a text.

The direction property is used to set the text direction.

The letter-spacing property is used to add or subtract space between the letters
that make up a word.

The word-spacing property is used to add or subtract space between the words of
a sentence.

The text-indent property is used to indent the text of a

paragraph. The text-align property is used to align the text

of a document.

The text-decoration property is used to underline, overline, and strikethrough


text.

The text-transform property is used to capitalize text or convert text to


uppercase or lowercase letters.

The white-space property is used to control the flow and formatting

of text. The text-shadow property is used to set the text shadow

around a text.

Set the Text Color

The following example demonstrates how to set the text color. Possible value could be
any color name in any valid format.

<html>
<head>
</head>
<body>
<p style=" color:red;" >
This text will be written in red.
</p>
</body>
</html>

Set the Text Direction


The following example demonstrates how to set the direction of a text. Possible values are
ltr or rtl.

<html>
<head>
</head>
<body>
<p style=" direction:rtl;" >
This text will be renedered from right to left
</p>
</body>
</html>
Set the Space between Characters
The following example demonstrates how to set the space between characters. Possible
values are
normal or a number specifying space..
</html>
<html>
<head>
</head>
<body>
<p style=" letter-spacing:5px;" >
This text is having space between letters.
</p>
</body>

Set the Space between Words


The following example demonstrates how to set the space between words. Possible values
are
normal or a number specifying space.

<html>
<head>
</head>
<body>
<p style=" word-spacing:5px;" >
This text is having space between words.
</p>
</body>
</html>

Set the Text Indent


The following example demonstrates how to indent the first line of a paragraph. Possible
values are % or a number specifying indent space.

<html>
<head>
</head>
<body>
<p style=" text-indent:1cm;" >
This text will have first line indented by 1cm and this line will remain at
its actual position this is done by CSS text-indent property.
</p>
</body>
</html>

Set the Text Alignment


The following example demonstrates how to align a text. Possible values are left, right,
center, justify.

<html>
<head>
</head>
<body>
<p style=" text-align:right;" >
Decorating the Text
The following example demonstrates how to decorate a text. Possible values are none,
underline, overline, line-through, blink.
</p>
<html>
<head>
<p style=" text-decoration:blink;" >
</head>
This text will have blinking effect
<body>
</p>
<p style=" text-decoration:underline;" >
</body>
This will be underlined
</html>
</p>

<p style=" text-decoration:line-through;"


> This will be striked through.
</p>

<p style=" text-decoration:overline;" >


This will have a over line.

Set the Text Cases


The following example demonstrates how to set the cases for a text. Possible values are
none, capitalize, uppercase, lowercase.

<html>
<head>
</head>
<body>
<p style=" text-transform:capitalize;" >
This will be capitalized
</p>

<p style=" text-transform:uppercase;" >


This will be in uppercase
</p>

<p style=" text-transform:lowercase;" >


This will be in lowercase
</p>
</body>

</html>

Set the White Space between Text


The following example demonstrates how white space inside an element is handled.
Possible values are normal, pre, nowrap.

<html>
<head>
</head>
<body>
<p style=" white-space:pre;" >
This text has a line break and the white-space pre setting tells the browser to
honor
it just like the HTML pre tag.</p>
</body>
</html>

Set the Text Shadow


The following example demonstrates how to set the shadow around a text. This may not
be supported by all the browsers.

<html>
<head>
</head>
<body>
<p style=" text-shadow:4 px 4 px 8px blue;" >
If your browser supports the CSS text-shadow property, this text will have a blue
shadow.
</p>
</body>
</html>

CSS - USING IMAGES


Images play an important role in any webpage. Though it is not recommended to include a
lot of images, but it is still important to use good images wherever required.

CSS plays a good role to control image display. You can set the following image
properties using CSS.

The border property is used to set the width of an image

border. The height property is used to set the height of

an image.

The width property is used to set the width of an image.

The -moz-opacity property is used to set the opacity of an image.

The Image Border Property

The border property of an image is used to set the width of an


image border. This property can have a value in length or in %.
A width of zero pixels means no

border. Here is the example −

<html>
<head>
</head>
<body>
<img style="border:0px;" src="/css/images/logo.png" />
<br />
<img style="border:3px dashed red;" src="/css/images/logo.png" />
</body>
</html>
The Image Height Property
The height property of an image is used to set the height of an image. This property can
have a value in length or in %. While giving value in %, it applies it in respect of the box
in which an image is available.

Here is an example −

<html>
<head>
</head>
<body>
<img style="border:1px solid red; height:100px;" src="/css/images/logo.png" />
<br />
<img style="border:1px solid red; height:50%;" src="/css/images/logo.png" />
</body>
</html>

The Image Width Property


The width property of an image is used to set the width of an image. This property can
have a value in length or in %. While giving value in %, it applies it in respect of the box
in which an image is available.
Here is an example −

<html>
<head>
</head>
<body>
<img style="border:1px solid red; width:150px;" src="/css/images/logo.png" />
<br />
<img style="border:1px solid red; width:100%;" src="/css/images/logo.png" />
</body>
</html>

The -moz-opacity Property


The -moz-opacity property of an image is used to set the opacity of an image. This
property is used to create a transparent image in Mozilla. IE uses filter:alphaopacity = x
to create transparent images.

In Mozilla −moz − opacity: x x can be a value from 0.0 - 1.0. A lower value makes the element
more transparent ThesamethingsgoesfortheCSS3 − validsyntaxopacity: x.

In IE filter: alpha(opacity = x) x can be a value from 0 - 100. A lower value makes the element
more transparent.

Here is an example −

<html>
<head>
</head>
<body>
<img style="border:1px solid red;-moz-opacity:0.4;filter:alpha(opacity=40);"
src="/css/images/logo.png" />
</body>
</html>

CSS - LINKS
This chapter teaches you how to set different properties of a hyper link using CSS. You can
set following properties of a hyper link −
We will revisit the same properties when we will discuss Pseudo-

Classes of CSS. The :link signifies unvisited hyperlinks.

The :visited signifies visited hyperlinks.

The :hover signifies an element that currently has the user's mouse pointer

hovering over it. The :active signifies an element on which the user is currently

clicking.

Usually, all these properties are kept in the header part of the HTML document.

Remember a:hover MUST come after a:link and a:visited in the CSS definition in order to
be effective. Also, a:active MUST come after a:hover in the CSS definition as follows −

<style type="text/css">
a:link {color: #000000}
a:visited {color: #006600}
a:hover {color: #FFCC00}
a:active {color: #FF00CC}
Now, we will see how to use these properties to give different effects to hyperlinks.

Set the Color of Links


The following example demonstrates how to set the link color. Possible values could be any
color name in any valid format.

<html>
<head>
<style type="text/css">
a:link {color:#000000}
</style>
</head>
<body>
<a href="/css/index.htm">Link</a>
</body>
</html>

Set the Color of Visited Links


The following example demonstrates how to set the color of visited links. Possible values
could be any color name in any valid format.
</body>
<html>
</html>
<head>
<style type="text/css">
a:visited {color: #006600}
</style>
</head>
<body>
<a href="/html/index.htm">Click this link</a>

Change the Color of Links when Mouse is Over


The following example demonstrates how to change the color of links when we bring a
mouse pointer over that link. Possible values could be any color name in any valid
format.

<html>
<head>
<style type="text/css">
a:hover {color: #FFCC00}
</style>
</head>
<body>
<a href="/css/index.htm">Link</a>
</body>
</html>

It will produce the following link. Now, you bring your mouse over this link and you will see
that it changes its color to yellow.

Change the Color of Active Links


The following example demonstrates how to change the color of active links. Possible
values could be any color name in any valid format.

<html>
<head>
<style type="text/css">
a:active {color: #FF00CC}
</style>
</head>
<body>
<a href="/html/index.htm">Link</a>
</body>
</html>

CSS - LISTS
Lists are very helpful in conveying a set of either numbered or bulleted points. This
chapter teaches you how to control list type, position, style, etc., using CSS.

We have the following five CSS properties, which can be used to control lists:

The list-style-type allows you to control the shape or appearance of the marker.

The list-style-position specifies whether a long point that wraps to a second line
should
align with the first line or start underneath the start of the marker.

The list-style-image specifies an image for the marker rather than a bullet
point or number.

The list-style serves as shorthand for the preceding properties.

The marker-offset specifies the distance between a marker and the text in the list.

Now, we will see how to use these properties with examples.

The list-style-type Property


The list-style-type property allows you to control the shape or style of bullet point
alsoknownasamarker
in the case of unordered lists and the style of numbering characters in

ordered lists. Here are the values which can be used for an unordered list −

Value Description

none NA

disc default A filled-in circle

circle An empty circle

square A filled-in

square

Here are the values, which can be used for an ordered list −

Value Description Example

decimal Number 1,2,3,4,5

decimal-leading-zero 0 before the number 01, 02, 03, 04,


05
lower-alpha Lowercase alphanumeric characters a, b, c, d, e

upper-alpha Uppercase alphanumeric characters A, B, C, D, E

lower-roman Lowercase Roman numerals i, ii, iii, iv, v

upper-roman Uppercase Roman numerals I, II, III, IV, V

lower-greek The marker is lower-greek alpha,


beta,
gamma
lower-latin The marker is lower-latin a, b, c, d, e

upper-latin The marker is upper-latin A, B, C, D, E

hebrew The marker is traditional Hebrew numbering

armenian The marker is traditional Armenian


numbering
georgian The marker is traditional Georgian
numbering
cjk-ideographic The marker is plain ideographic numbers

hiragana The marker is hiragana a, i, u, e, o, ka, ki

katakana The marker is katakana A, I, U, E, O, KA, KI

hiragana-iroha The marker is hiragana-iroha i, ro, ha, ni, ho,


he, to
Here is an example −

<html>
<head>
</head>
<body>
<ul style="list-style-type:circle;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ul style="list-style-type:square;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style-type:decimal;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

<ol style="list-style-type:lower-alpha;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

<ol style="list-style-type:lower-roman;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>
</body>
</html>

The list-style-position Property


The list-style-position property indicates whether the marker should appear inside or
outside of the box containing the bullet points. It can have one the two values −

Value Description

none NA

inside If the text goes onto a second line, the text will wrap underneath the marker. It
will also
appear indented to where the text would have started if the list had a value of
outside.

outside If the text goes onto a second line, the text will be aligned with the start of the
first line
totherightofthebullet.

Here is an example −

<html>
<head>
</head>
<body>
<ul style="list-style-type:circle; list-stlye-position:outside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ul style="list-style-type:square;list-style-position:inside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style-type:decimal;list-stlye-position:outside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

<ol style="list-style-type:lower-alpha;list-style-position:inside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>
</body>
</html>

The list-style-image Property


The list-style-image allows you to specify an image so that you can use your own bullet
style. The syntax is similar to the background-image property with the letters url starting
the value of the property followed by the URL in brackets. If it does not find the given
image then default bullets are used.

Here is an example −

<html>
<head>
</head>
<body>
<ul>
<li style="list-style-image: url(/images/bullet.gif);">Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol>
<li style="list-style-image: url(/images/bullet.gif);">Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>
</body>
</html>

The list-style Property


The list-style allows you to specify all the list properties into a single expression. These
properties can appear in any order.

Here is an example −

<html>
<head>
</head>
<body>
<ul style="list-style: inside square;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style: outside upper-alpha;">


<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>
</body>
</html>

The marker-offset Property


The marker-offset property allows you to specify the distance between the marker and the
text relating to that marker. Its value should be a length as shown in the following example

Unfortunately, this property is not supported in IE 6 or

Netscape 7. Here is an example −

<html>
<head>
</head>
<body>
<ul style="list-style: inside square; marker-offset:2em;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style: outside upper-alpha; marker-offset:2cm;">


<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>
</body>
</html>
CSS - PSEUDO CLASSES
CSS pseudo-classes are used to add special effects to some selectors. You do not need
to use JavaScript or any other script to use those effects. A simple syntax of pseudo-
classes is as follows:

selector:pseudo-class {property: value}

CSS classes can also be used with pseudo-classes:

selector.class:pseudo-class {property: value}

The most commonly used pseudo-classes are as follows −

Value Description

:link Use this class to add special style to an unvisited link.

:visited Use this class to add special style to a visited link.

:hover Use this class to add special style to an element when you mouse over it.

:active Use this class to add special style to an active element.

:focus Use this class to add special style to an element while the element has focus.
:first- Use this class to add special style to an element that is the first child of
child some other element.

:lang Use this class to specify a language to use in a specified element.

While defining pseudo-classes in a <style>...</style> block, following points should

be noted − a:hover MUST come after a:link and a:visited in the CSS definition in

order to be effective. a:active MUST come after a:hover in the CSS definition in

order to be effective.

Pseudo-class names are not case-sensitive.

Pseudo-class are different from CSS classes but they can be combined.

The :link pseudo-class


The following example demonstrates how to use the :link class to set the link color.
Possible values could be any color name in any valid format.

<html>
<head>
<style type="text/css">
a:link {color:#000000}
</style>
</head>
<body>
<a href="/html/index.htm">Black Link</a>
</body>
</html>

The :visited pseudo-class


The following is the example which demonstrates how to use the :visited class to set the
color of visited links. Possible values could be any color name in any valid format.

<html>
<head>
<style type="text/css">
a:visited {color: #006600}
</style>
</head>
<body>
<a href="/html/index.htm">Click this link</a>
</body>
</html>

This will produce following link. Once you will click this link, it will change its color to green.
The :hover pseudo-class
The following example demonstrates how to use the :hover class to change the color of
links when we bring a mouse pointer over that link. Possible values could be any color
name in any valid format.

<html>
<head>
<style type="text/css">
a:hover {color: #FFCC00}
</style>
</head>
<body>
<a href="/html/index.htm">Bring Mouse Here</a>
</body>
</html>

The :active pseudo-class


The following example demonstrates how to use the :active class to change the color of
active links. Possible values could be any color name in any valid format.

<html>
<head>
<style type="text/css">
a:active {color: #FF00CC}
</style>
</head>
<body>
<a href="/html/index.htm">Click This Link</a>
</body>
</html>

It will produce the following link. When a user clicks it, the color changes to pink.
The :focus pseudo-class
The following example demonstrates how to use the :focus class to change the color of
focused links. Possible values could be any color name in any valid format.

<html>
<head>
<style type="text/css">
a:focus {color: #0000FF}
</style>
</head>
<body>
<a href="/html/index.htm">Click this Link</a>
</body>
</html>

It will produce the following link. When this link gets focused, its color changes to orange.
The color changes back when it loses focus.

The :first-child pseudo-class


The :first-child pseudo-class matches a specified element that is the first child of another
element and adds special style to that element that is the first child of some other
element.

To make :first-child work in IE <!DOCTYPE> must be declared at the top of document.

For example, to indent the first paragraph of all <div> elements, you could use this
definition:

<html>
<head>
<style type="text/css">
div > p:first-child
{
text-indent: 25px;
}
</style>
</head>
<body>
<div>
<p>
First paragraph in div. This paragraph will be indented
</p>

<p>
Second paragraph in div. This paragraph will not be indented
</p>
</div>
<p>But it will not match the paragraph in this HTML:</p>
<div>
<h3>Heading</h3>

<p>The first paragraph inside the div. This paragraph will not be effected.</p>
</div>
</body>
</html>

The :lang pseudo-class


The language pseudo-class :lang, allows constructing selectors based on the language
setting for specific tags.

This class is useful in documents that must appeal to multiple languages that have
different conventions for certain language constructs. For example, the French
language typically uses angle brackets < and > for quoting purposes, while the English
language uses quote marks ′and′.

In a document that needs to address this difference, you can use the :lang pseudo-class
to change the quote marks appropriately. The following code changes the
<blockquote> tag appropriately for the language being used −

<html>
<head>
<style type="text/css">
/* Two levels of quotes for two languages*/
:lang(en) { quotes: '"' '"' "'" "'"; }
:lang(fr) { quotes: "<<" ">>" "<" ">"; }
</style>
</head>
<body>
<p>...<q lang="fr">A quote in a paragraph</q>...</p>
</body>
</html>

The :lang selectors will apply to all the elements in the document. However, not all
elements make use of the quotes property, so the effect will be transparent for most
elements.

CSS - PSEUDO ELEMENTS


CSS pseudo-elements are used to add special effects to some selectors. You do not need to
use JavaScript or any other script to use those effects. A simple syntax of pseudo-element
is as follows

selector:pseudo-element {property: value}

CSS classes can also be used with pseudo-elements −

selector.class:pseudo-element {property: value}

The most commonly used pseudo-elements are as follows −

Value Description
:first-line Use this element to add special styles to the first line of the text in a selector.

:first-letter Use this element to add special style to the first letter of the text in a selector.

:before Use this element to insert some content before an element.

:after Use this element to insert some content after an element.

The :first-line pseudo-element


The following example demonstrates how to use the :first-line element to add special
effects to the first line of elements in the document.

<html>
<head>
<style type="text/css">
p:first-line { text-decoration: underline; }
p.noline:first-line { text-decoration: none; }
</style>
</head>
<body>
<p > This line would not have any underline because this belongs to nline
class.</p>

<p>The first line of this paragraph will be underlined as defined in the CSS rule
above. Rest of the lines in this paragraph will remain normal. This example shows how to
use :first-line pseduo element to give effect to the first line of any HTML element.</p>
</body>
</html>

The :first-letter pseudo-element


The following example demonstrates how to use the :first-letter element to add special
effects to the first letter of elements in the document.

<html>
<head>
<style type="text/css">
p:first-letter { font-size: 5em; }
p.normal:first-letter { font-size: 10px; }
</style>
</head>
<body>
<p > First character of this paragraph will be normal and will have font size 10
px;</p>

<p>The first character of this paragraph will be 5em big as defined in the CSS
rule above. Rest of the characters in this paragraph will remain normal. This example
shows how to use :first-letter pseduo element to give effect to the first characters of
any HTML element.</p>
</body>
</html>

The :before pseudo-element


The following example demonstrates how to use the :before element to add some
content before any element.

<html>
<head>
<style type="text/css">
p:before
{
The :after pseudo-element

The following example demonstrates how to use the :after element to add some content
after any element.

<html>
<head>
<style type="text/css">
p:after
{
content: url(/images/bullet.gif)
}
</style>
</head>
<body>
<p> This line will be succeeded by a bullet.</p>
<p> This line will be succeeded by a bullet.</p>
<p> This line will be succeeded by a bullet.</p>
</body>
</html>

CSS3 - INTRODUCTION
Cascading Style Sheets CSS is a style sheet language used for describing the look and
formatting of a document written in a markup language.CSS3 is a latest standard of css
earlier versionsCSS2.The main difference between css2 and css3 is follows

Media
Queries
Namespaces
Selectors Level
3 Color

CSS3 modules
CSS3 is collaboration of CSS2 specifications and new specifications, we can called
this collaboration is module.Some of the modules are shown below

Selectors
Box
Model
Backgrounds
Image Values and Replaced
Content Text Effects

2D
Transformations
3D
Transformations
Animations
Multiple Column
Layout User Interface

CSS3 - COLORS
CSS3 has Supported additional color properties as

follows − RGBA colors


HSL colors
HSLA
colors
Opacity

RGBA stands for Red Green Blue Alpha.It is an extension of CSS2,Alpha specifies
the opacity of a color and parameter number is a numerical between 0.0 to 1.0. A
Sample syntax of RGBA as shown below −

#d1 {background-color: rgba(255, 0, 0, 0.5);}


#d2 {background-color: rgba(0, 255, 0, 0.5);}
#d3 {background-color: rgba(0, 0, 255, 0.5);}

HSL stands for huge, saturation, lightness.Here Huge is a degree on the color
wheel, saturation and lightness are percentage values between 0 to 100%. A Sample
syntax of HSL as shown below

#g1 {background-color: hsl(120, 100%, 50%);}


#g2 {background-color: hsl(120, 100%, 75%);}
#g3 {background-color: hsl(120, 100%, 25%);}

HSLA stands for huge, saturation, lightness and alpha. Alpha value specifies the
opacity as shown RGBA. A Sample syntax of HSLA as shown below −

#g1 {background-color: hsla(120, 100%, 50%, 0.3);}


#g2 {background-color: hsla(120, 100%, 75%, 0.3);}
#g3 {background-color: hsla(120, 100%, 25%, 0.3);}

opacity is a thinner paints need black added to increase opacity. A sample syntax of
opacity is as shown below −

#g1 {background-color:rgb(255,0,0);opacity:0.6;}
#g2 {background-color:rgb(0,255,0);opacity:0.6;}
#g3 {background-color:rgb(0,0,255);opacity:0.6;}

The following example shows rgba color property

<html>
<head>
<style>
#p1 {background-color:rgba(255,0,0,0.3);}
#p2 {background-color:rgba(0,255,0,0.3);}
#p3 {background-color:rgba(0,0,255,0.3);}
</style>
</head>
<body>
<p>RGBA colors:</p>
The following example shows HSL color property
</body>
<html>
</html>
<head>
<style>
#g1 {background-color:hsl(120, 100%, 50%);}
#g2 {background-color:hsl(120,100%,75%);}
#g3 {background-color:hsl(120,100%,25%);}
</style>
</head>
<body>
<p>HSL colors:</p>
<p >Green</p>
<p >Normal Green</p>
<p >Dark Green</p>

The following example shows HSLA color property

<html>
<head>
<style>
#d1 {background-color:hsla(120,100%,50%,0.3);}
#d2 {background-color:hsla(120,100%,75%,0.3);}
#d3 {background-color:hsla(120,100%,25%,0.3);}
</style>
</head>
<body>
<p>HSLA colors:</p>
<p >Less opacity green</p>
<p >Green</p>
<p >Green</p>
</body>
</html>

The following example shows Opacity property

<html>
<head>
<style>
#m 1 {background-
color:rgb(255,0,0);opacity:0.6;} #m 2
{background-color:rgb(0,255,0);opacity:0.6;} #m
3 {background-color:rgb(0,0,255);opacity:0.6;}
</style>
</head>
<body>
<p>HSLA colors:</p>
<p >Red</p>
<p >Green</p>
<p >Blue</p>
</body>
</html>

CSS3 - TEXT
CSS3 contained several extra features, which is added
later on text-overflow
word-
wrap
word-break

There are following most commonly used property in CSS3

Values Description

text-align-last Used to align the last line of the

text text-emphasis Used to emphasis text and

color

text-overflow used to determines how overflowed content that is not displayed is


signaled to users

word-break Used to break the line based on word

word-wrap Used to break the line and wrap onto next line

Text-overflow
The text-overflow property determines how overflowed content that is not displayed is
signaled to users. the sample example of text overflow is shown as follows −

<html>
<head>
<style>
p.text1 {
white-space: nowrap;
width: 200px;
border: 1px solid #000000;
overflow: hidden;
text-overflow: clip;
}
p.text2 {
white-space: nowrap;
width: 200px;
border: 1px solid #000000;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<b>Original Text:</b>

<p>Tutorials Point originated from the idea that there exists a class of
readers who respond better to online content and prefer to learn new skills at
their own pace from the comforts of their drawing rooms.</p>
<b>Text overflow:clip:</b>

<p >Tutorials Point originated from the idea that there exists
a class of readers who respond better to online content and prefer to learn
new skills at their own pace from the comforts of their drawing rooms.</p>

<b>Text overflow:ellipsis</b>

<p >Tutorials Point originated from the idea that there exists
a class of readers who respond better to online content and prefer to learn
new skills at their own pace from the comforts of their drawing rooms.</p>
</body>
</html>

CSS3 Word Breaking


Used to break the line, following code shows the sample code of word breaking

<html>
<head>
<style>
p.text1 {
width: 140px;
border: 1px solid #000000;
word-break: keep-all;
}
p.text2 {
width: 140px;
border: 1px solid #000000;
word-break: break-all;
}
</style>
</head>
<body>
<b>line break at hyphens:</b>
<p >Tutorials Point originated from the idea that there exists a class of
readers who respond better to online content and prefer to learn new skills at
their own pace from the comforts of their drawing rooms.</p>

<b>line break at any character</b>

<p >Tutorials Point originated from the idea that there exists a class of
readers who respond better to online content and prefer to learn new skills at
their
own pace from the comforts of their drawing rooms.</p>
</body>
</html>

CSS word wrapping


Word wrapping is used to break the line and wrap onto next line.the following code will
have sample syntax

p {
word-wrap: break-word;
}

You might also like