CSS Quick Guide
CSS Quick Guide
What is CSS?
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.
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.
https://www.tutorialspoint.com/css/css_quick_guide.htm 1/160
5/27/2019 CSS Quick Guide
CSS Versions
Cascading Style Sheets level 1 (CSS1) 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 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.
CSS - Syntax
selector { property: value }
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.
h1 {
color: #36CFFF;
}
https://www.tutorialspoint.com/css/css_quick_guide.htm 2/160
5/27/2019 CSS Quick Guide
* {
color: #000000;
}
This rule renders the content of every element in our document in black.
ul em {
color: #000000;
}
.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 −
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;
https://www.tutorialspoint.com/css/css_quick_guide.htm 3/160
5/27/2019 CSS Quick Guide
}
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.
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.
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.
https://www.tutorialspoint.com/css/css_quick_guide.htm 4/160
5/27/2019 CSS Quick Guide
p[lang="fr"] − Selects all paragraph elements whose lang attribute has a value
of exactly "fr".
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 semicolon (;). You can keep
them in a single line or multiple lines. For better readability, we keep them in 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.
https://www.tutorialspoint.com/css/css_quick_guide.htm 5/160
5/27/2019 CSS Quick Guide
CSS - Inclusion
<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 −
This is a heading
This is a paragraph.
Attributes
Attributes associated with <style> elements are −
type text/css Specifies the style sheet language as a content-type (MIME type).
This is required attribute.
media screen
tty
tv
projection
Specifies the device the document will be displayed on. Default value
handheld
is all. This is an optional attribute.
print
braille
aural
all
https://www.tutorialspoint.com/css/css_quick_guide.htm 6/160
5/27/2019 CSS Quick Guide
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 −
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 −
Live Demo
<html>
<head>
</head>
<body>
<h1 style = "color:#36C;">
This is inline CSS
</h1>
</body>
</html>
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.
<head>
<link type = "text/css" href = "..." media = "..." />
</head>
Attributes
https://www.tutorialspoint.com/css/css_quick_guide.htm 7/160
5/27/2019 CSS Quick Guide
href Specifies the style sheet file having Style rules. This attribute
URL
is a required.
media screen
tty
tv
projection
Specifies the device the document will be displayed on.
handheld
Default value is all. This is optional attribute.
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>
https://www.tutorialspoint.com/css/css_quick_guide.htm 8/160
5/27/2019 CSS Quick Guide
<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>
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.
https://www.tutorialspoint.com/css/css_quick_guide.htm 9/160
5/27/2019 CSS Quick Guide
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
Live Demo
<!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>
Hello World!
CSS - Colors
https://www.tutorialspoint.com/css/css_quick_guide.htm 10/160
5/27/2019 CSS Quick Guide
Hex Code #RRGGBB p{color:#FF0000;} Short Hex Code #RGB p{color:#6A7;} RGB %
rgb(rrr%,ggg%,bbb%) p{color:rgb(50%,50%,50%);} RGB Absolute rgb(rrr,ggg,bbb)
p{color:rgb(0,0,255);} keyword aqua, black, etc. p{color:teal;}
These formats are explained in more detail in the following sections −
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.
#000000
#FF0000
#00FF00
#0000FF
#FFFF00
#00FFFF
#FF00FF
#C0C0C0
#FFFFFF
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.
https://www.tutorialspoint.com/css/css_quick_guide.htm 11/160
5/27/2019 CSS Quick Guide
#000
#F00
#0F0
#0FF
#FF0
#0FF
#F0F
#FFF
NOTE − All the browsers does not support rgb() property of color so it is recommended
not to use it.
rgb(0,0,0)
rgb(255,0,0)
rgb(0,255,0)
rgb(0,0,255)
rgb(255,255,0)
rgb(0,255,255)
rgb(255,0,255)
rgb(192,192,192)
rgb(255,255,255)
You can build millions of color codes using our Color Code Builder. Check our HTML Color
Code Builder. To use this tool, you would need a Java Enabled Browser.
https://www.tutorialspoint.com/css/css_quick_guide.htm 13/160
5/27/2019 CSS Quick Guide
CSS - Backgrounds
Set the Background Color
Following is the example which demonstrates how to set the background color for an
element.
Live Demo
<html>
<head>
</head>
<body>
<p style = "background-color:yellow;">
This text has a yellow background color.
</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 14/160
5/27/2019 CSS Quick Guide
<body>
<h1>Hello World!</h1>
</body>
<html>
Hello World!
<body>
<p>Tutorials point</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 15/160
5/27/2019 CSS Quick Guide
Tutorials point
The following example which demonstrates how to repeat the background image vertically.
Live Demo
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-repeat: repeat-y;
}
</style>
</head>
<body>
<p>Tutorials point</p>
</body>
</html>
Tutorials point
The following example demonstrates how to repeat the background image horizontally.
Live Demo
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-repeat: repeat-x;
}
</style>
</head>
<body>
<p>Tutorials point</p>
</body>
</html>
Tutorials point
https://www.tutorialspoint.com/css/css_quick_guide.htm 16/160
5/27/2019 CSS Quick Guide
body {
background-image: url("/css/images/css.jpg");
background-position:100px;
}
</style>
</head>
<body>
<p>Tutorials point</p>
</body>
</html>
Tutorials point
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.
Live Demo
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-position:100px 200px;
}
</style>
</head>
<body>
<p>Tutorials point</p>
</body>
</html>
Tutorials point
The following example demonstrates how to set the fixed background image.
Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('/css/images/css.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
https://www.tutorialspoint.com/css/css_quick_guide.htm 17/160
5/27/2019 CSS Quick Guide
</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>
If you do not see any scrollbars, try to resize the browser window.
The following example demonstrates how to set the scrolling background image.
Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
https://www.tutorialspoint.com/css/css_quick_guide.htm 18/160
5/27/2019 CSS Quick Guide
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>
If you do not see any scrollbars, try to resize the browser window.
https://www.tutorialspoint.com/css/css_quick_guide.htm 19/160
5/27/2019 CSS Quick Guide
Shorthand Property
You can use the background property to set all the background properties at once. For
example −
CSS - Fonts
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.
Live Demo
<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>
This text is rendered in either georgia, garamond, or the default serif font depending on which
font you have at your system.
<body>
<p style = "font-style:italic;">
This text will be rendered in italic style
</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 20/160
5/27/2019 CSS Quick Guide
<body>
<p style = "font-variant:small-caps;">
This text will be rendered as small caps
</p>
</body>
</html>
<body>
<p style = "font-weight:bold;">
This font is bold.
</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 21/160
5/27/2019 CSS Quick Guide
<body>
<p style = "font-size:20px;">
This font size is 20 pixels
</p>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 22/160
5/27/2019 CSS Quick Guide
<body>
<p style = "font-stretch:ultra-expanded;">
If this doesn't appear to work, it is likely that your computer
doesn't have a <br>condensed or expanded version of the font being used.
</p>
</body>
</html>
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.
Shorthand Property
You can use the font property to set all the font properties at once. For example −
Live Demo
<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>
https://www.tutorialspoint.com/css/css_quick_guide.htm 23/160
5/27/2019 CSS Quick Guide
A .
CSS - Text
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.
<body>
<p style = "color:red;">
This text will be written in red.
</p>
</body>
</html>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 24/160
5/27/2019 CSS Quick Guide
<body>
<p style = "letter-spacing:5px;">
This text is having space between letters.
</p>
</body>
</html>
<body>
<p style = "word-spacing:5px;">
This text is having space between words.
</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 25/160
5/27/2019 CSS Quick Guide
<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>
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.
<body>
<p style = "text-align:right;">
This will be right aligned.
</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 26/160
5/27/2019 CSS Quick Guide
<body>
<p style = "text-decoration:underline;">
This will be underlined
</p>
<body>
<p style = "text-transform:capitalize;">
This will be capitalized
</p>
<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>
This text has a line break and the white-space pre setting tells the browser to honor
it just like the HTML pre tag.
https://www.tutorialspoint.com/css/css_quick_guide.htm 28/160
5/27/2019 CSS Quick Guide
<body>
<p style = "text-shadow:4px 4px 8px blue;">
If your browser supports the CSS text-shadow property,
this text will have a blue shadow.
</p>
</body>
</html>
IfIfyour
yourbrowser
browsersupports
supportsthe
theCSS
CSStext-shadow
text-shadowproperty,
property,this
thistext
textwill
willhave
haveaablue
blueshadow.
shadow.
<body>
<img style = "border:0px;" src = "/css/images/logo.png" />
<br />
<img style = "border:3px dashed red;" src = "/css/images/logo.png" />
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 29/160
5/27/2019 CSS Quick Guide
Here is an example −
Live Demo
<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>
Here is an example −
Live Demo
<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>
https://www.tutorialspoint.com/css/css_quick_guide.htm 30/160
5/27/2019 CSS Quick Guide
In Mozilla (-moz-opacity:x) x can be a value from 0.0 - 1.0. A lower value makes the
element more transparent (The same things goes for the CSS3-valid syntax opacity:x).
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<img style = "border:1px solid red; -moz-opacity:0.4; filter:alpha(opacity=40);" src = "/cs
</body>
</html>
CSS - Links
Usually, all these properties are kept in the header part of the HTML document.
https://www.tutorialspoint.com/css/css_quick_guide.htm 31/160
5/27/2019 CSS Quick Guide
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 −
Now, we will see how to use these properties to give different effects to hyperlinks.
<body>
<a href = "">Link</a>
</body>
</html>
Link
<body>
<a href = ""> link</a>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 32/160
5/27/2019 CSS Quick Guide
It will produce the following link. Once you will click this link, it will change its color to
green.
link
<body>
<a href = "">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.
Link
<body>
<a href = "">Link</a>
</body>
</html>
It will produce the following link. It will change its color to pink when the user clicks it.
Link
CSS - Tables
https://www.tutorialspoint.com/css/css_quick_guide.htm 33/160
5/27/2019 CSS Quick Guide
td.a {
border-style:dotted;
border-width:3px;
border-color:#000000;
padding: 10px;
}
td.b {
border-style:solid;
border-width:3px;
border-color:#333333;
padding:10px;
}
</style>
</head>
<body>
<table class = "one">
<caption>Collapse Border Example</caption>
<tr><td class = "a"> Cell A Collapse Example</td></tr>
<tr><td class = "b"> Cell B Collapse Example</td></tr>
</table>
<br />
https://www.tutorialspoint.com/css/css_quick_guide.htm 34/160
5/27/2019 CSS Quick Guide
If you provide one value, it will applies to both vertical and horizontal borders. Or you can
specify two values, in which case, the first refers to the horizontal spacing and the second
to the vertical spacing −
<style type="text/css">
/* If you provide one value */
table.example {border-spacing:10px;}
/* This is how you can provide two values */
table.example {border-spacing:10px; 15px;}
</style>
Now let's modify the previous example and see the effect −
Live Demo
<html>
<head>
<style type = "text/css">
table.one {
border-collapse:separate;
width:400px;
border-spacing:10px;
}
table.two {
border-collapse:separate;
width:400px;
border-spacing:10px 50px;
}
</style>
</head>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 35/160
5/27/2019 CSS Quick Guide
</body>
</html>
This property can have one of the four values top, bottom, left or right. The following
example uses each value.
caption.right {caption-side:right}
</style>
</head>
<body>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 37/160
5/27/2019 CSS Quick Guide
Cell A
Cell B
This caption will appear at the bottom
This property can have one of the three values - show, hide or inherit.
Here is the empty-cells property used to hide borders of empty cells in the <table>
element.
Live Demo
<html>
<head>
<style type = "text/css">
table.empty {
width:350px;
border-collapse:separate;
empty-cells:hide;
}
td.empty {
padding:5px;
border-style:solid;
border-width:1px;
border-color:#999999;
}
</style>
</head>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 38/160
5/27/2019 CSS Quick Guide
<tr>
<th>Row Title</th>
<td class = "empty">value</td>
<td class = "empty">value</td>
</tr>
<tr>
<th>Row Title</th>
<td class = "empty">value</td>
<td class = "empty"></td>
</tr>
</table>
</body>
</html>
This property can have one of the three values: fixed, auto or inherit.
NOTE − This property is not supported by many browsers so do not rely on this property.
Live Demo
<html>
<head>
<style type = "text/css">
table.auto {
table-layout: auto
}
table.fixed {
table-layout: fixed
}
</style>
</head>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 39/160
5/27/2019 CSS Quick Guide
<br />
</body>
</html>
CSS - Borders
The border-color property allows you to change the color of the border surrounding an
element. You can individually change the color of the bottom, left, top and right sides of an
element's border using the properties −
<body>
<p class = "example1">
https://www.tutorialspoint.com/css/css_quick_guide.htm 40/160
5/27/2019 CSS Quick Guide
inset − Border makes the box look like it is embedded in the page.
outset − Border makes the box look like it is coming out of the canvas.
You can individually change the style of the bottom, left, top, and right borders of an
element using the following properties −
https://www.tutorialspoint.com/css/css_quick_guide.htm 41/160
5/27/2019 CSS Quick Guide
<html>
<head>
</head>
<body>
<p style = "border-width:4px; border-style:none;">
This is a border with none width.
</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 42/160
5/27/2019 CSS Quick Guide
You can individually change the width of the bottom, top, left, and right borders of an
element using the following properties −
<body>
<p style = "border-width:4px; border-style:solid;">
This is a solid border whose width is 4px.
</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 43/160
5/27/2019 CSS Quick Guide
The following example shows how to use all the three properties into a single property.
This is the most frequently used property to set border around any element.
Live Demo
<html>
<head>
</head>
<body>
<p style = "border:4px solid red;">
This example is showing shorthand property for border.
</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 44/160
5/27/2019 CSS Quick Guide
CSS - Margins
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "margin: 15px; border:1px solid black;">
all four margins will be 15px
</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 45/160
5/27/2019 CSS Quick Guide
top and bottom margin will be 10px, left and right margin will be 2% of the total width of the
document.
top margin will be 10px, left and right margin will be 2% of the total width of the document, bottom
margin will be -10px
top margin will be 10px, right margin will be 2% of the total width of the document, bottom margin
will be -10px, left margin will be set by the browser
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "margin-bottom: 15px; border:1px solid black;">
This is a paragraph with a specified bottom margin
</p>
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 46/160
5/27/2019 CSS Quick Guide
<p style = "margin-top: 15px; border:1px solid black;">
This is a paragraph with a specified top margin
</p>
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "margin-left: 15px; border:1px solid black;">
This is a paragraph with a specified left margin
</p>
Here is an example −
https://www.tutorialspoint.com/css/css_quick_guide.htm 47/160
5/27/2019 CSS Quick Guide
<body>
<p style = "margin-right: 15px; border:1px solid black;">
This is a paragraph with a specified right margin
</p>
<p style = "margin-right: 5%; border:1px solid black;">
This is another paragraph with a specified right margin in percent
</p>
</body>
</html>
CSS - Lists
Now, we will see how to use these properties with examples.
Here are the values which can be used for an unordered list −
1 none
NA
2 disc (default)
A filled-in circle
3 circle
An empty circle
4 square
A filled-in square
https://www.tutorialspoint.com/css/css_quick_guide.htm 48/160
5/27/2019 CSS Quick Guide
Here are the values, which can be used for an ordered list −
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<ul style = "list-style-type:circle;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
https://www.tutorialspoint.com/css/css_quick_guide.htm 49/160
5/27/2019 CSS Quick Guide
</ul>
Maths
Social Science
Physics
Maths
Social Science
Physics
1. Maths
2. Social Science
3. Physics
a. Maths
b. Social Science
c. Physics
i. Maths
ii. Social Science
iii. Physics
https://www.tutorialspoint.com/css/css_quick_guide.htm 50/160
5/27/2019 CSS Quick Guide
1 none
NA
2 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.
3 outside
If the text goes onto a second line, the text will be aligned with the start of the
first line (to the right of the bullet).
Here is an example −
Live Demo
<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>
https://www.tutorialspoint.com/css/css_quick_guide.htm 51/160
5/27/2019 CSS Quick Guide
Maths
Social Science
Physics
Maths
Social Science
Physics
1. Maths
2. Social Science
3. Physics
a. Maths
b. Social Science
c. Physics
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<ul>
<li style = "list-style-image: url(/https/www.scribd.com/images/bullet.gif);">Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>
<ol>
<li style = "list-style-image: url(/https/www.scribd.com/images/bullet.gif);">Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 52/160
5/27/2019 CSS Quick Guide
Maths
Social Science
Physics
Maths
2. Social Science
3. Physics
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<ul style = "list-style: inside square;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>
Maths
Social Science
Physics
A. Maths
B. Social Science
C. Physics
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<ul style = "list-style: inside square; marker-offset:2em;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>
Maths
Social Science
Physics
A. Maths
B. Social Science
C. Physics
CSS - Paddings
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "padding-bottom: 15px; border:1px solid black;">
This is a paragraph with a specified bottom padding
</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 54/160
5/27/2019 CSS Quick Guide
<p style = "padding-bottom: 5%; border:1px solid black;">
This is another paragraph with a specified bottom padding in percent
</p>
</body>
</html>
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "padding-top: 15px; border:1px solid black;">
This is a paragraph with a specified top padding
</p>
Here is an example −
https://www.tutorialspoint.com/css/css_quick_guide.htm 55/160
5/27/2019 CSS Quick Guide
<body>
<p style = "padding-left: 15px; border:1px solid black;">
This is a paragraph with a specified left padding
</p>
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "padding-right: 15px; border:1px solid black;">
This is a paragraph with a specified right padding
</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 56/160
5/27/2019 CSS Quick Guide
The padding property sets the left, right, top and bottom padding (space) of an element.
This can take a value in terms of length of %.
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "padding: 15px; border:1px solid black;">
all four padding will be 15px
</p>
top and bottom padding will be 10px, left and right padding will be 2% of the total width of the
document.
top padding will be 10px, left and right padding will be 2% of the total width of the document,
bottom padding will be 10px
top padding will be 10px, right padding will be 2% of the total width of the document, bottom
padding and top padding will be 10px
CSS - Cursors
1
auto
https://www.tutorialspoint.com/css/css_quick_guide.htm 57/160
5/27/2019 CSS Quick Guide
Shape of the cursor depends on the context area it is over. For example an I over text, a
hand over a link, and so on...
2
crosshair
3
default
An arrow
4
pointer
5
move
The I bar
6
e-resize
7
ne-resize
The cursor indicates that an edge of a box is to be moved up and right (north/east)
8
nw-resize
The cursor indicates that an edge of a box is to be moved up and left (north/west)
9
n-resize
10
se-resize
The cursor indicates that an edge of a box is to be moved down and right (south/east)
11
sw-resize
The cursor indicates that an edge of a box is to be moved down and left (south/west)
12
https://www.tutorialspoint.com/css/css_quick_guide.htm 58/160
5/27/2019 CSS Quick Guide
s-resize
13
w-resize
14
text
The I bar
15
wait
An hour glass
16
help
17
<url>
NOTE − You should try to use only these values to add helpful information for users, and
in places, they would expect to see that cursor. For example, using the crosshair when
someone hovers over a link can confuse visitors.
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p>Move the mouse over the words to see the cursor change:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 59/160
5/27/2019 CSS Quick Guide
<div style = "cursor:w-resize">w-resize</div>
Move the mouse over the words to see the cursor change:
Auto
Crosshair
Default
Pointer
Move
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
text
wait
help
CSS - Outlines
The outline-width property is used to set the width of the outline.
The outline-style property is used to set the line style for the outline.
The outline property is used to set all the above three properties in a single
statement.
Here is an example −
Live Demo
<html>
<head>
https://www.tutorialspoint.com/css/css_quick_guide.htm 60/160
5/27/2019 CSS Quick Guide
</head>
<body>
<p style = "outline-width:thin; outline-style:solid;">
This text is having thin outline.
</p>
<br />
inset − Outline makes the box look like it is embedded in the page.
outset − Outline makes the box look like it is coming out of the canvas.
https://www.tutorialspoint.com/css/css_quick_guide.htm 61/160
5/27/2019 CSS Quick Guide
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "outline-width:thin; outline-style:solid;">
This text is having thin solid outline.
</p>
<br />
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "outline-width:thin; outline-style:solid;outline-color:red">
This text is having thin solid red outline.
</p>
<br />
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "outline:thin solid red;">
This text is having thin solid red outline.
</p>
<br />
https://www.tutorialspoint.com/css/css_quick_guide.htm 63/160
5/27/2019 CSS Quick Guide
CSS - Dimension
The max-width property is used to set the maximum width that a box can be.
The min-width property is used to set the minimum width that a box can be.
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "width:400px; height:100px; border:1px solid red; padding:5px; margin:10px;">
This paragraph is 400pixels wide and 100 pixels high
</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 64/160
5/27/2019 CSS Quick Guide
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "width:400px; height:100px; border:1px solid red; padding:5px; margin:10px; line
This paragraph is 400pixels wide and 100 pixels high and here line height is 30pixels.
This paragraph is 400 pixels wide and 100 pixels high and here line height is 30pixels.
</p>
</body>
</html>
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "width:400px; max-height:10px; border:1px solid red; padding:5px; margin:10px;">
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
</p>
<br>
<br>
<br>
<img alt = "logo" src = "/css/images/logo.png" width = "195" height = "84" />
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 65/160
5/27/2019 CSS Quick Guide
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "width:400px; min-height:200px; border:1px solid red; padding:5px; margin:10px;"
This paragraph is 400px wide and min height is 200px
This paragraph is 400px wide and min height is 200px
This paragraph is 400px wide and min height is 200px
This paragraph is 400px wide and min height is 200px
</p>
<img alt = "logo" src = "/css/images/logo.png" width = "95" height = "84" />
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 66/160
5/27/2019 CSS Quick Guide
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "max-width:100px; height:200px; border:1px solid red; padding:5px; margin:10px;"
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
</p>
<img alt = "logo" src = "/images/css.gif" width = "95" height = "84" />
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 67/160
5/27/2019 CSS Quick Guide
This paragraph
is 200px high
and max width
is 100px This
paragraph is
200px high and
max width is
100px This
paragraph is
200px high and
max width is
100px This
paragraph is
200px high and
max width is
100px This
paragraph is
200px high and
max width is
100px
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p style = "min-width:400px; height:100px; border:1px solid red; padding:5px; margin:10px;"
This paragraph is 100px high and min width is 400px
This paragraph is 100px high and min width is 400px
</p>
<img alt = "logo" src = "/css/images/css.gif" width = "95" height = "84" />
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 68/160
5/27/2019 CSS Quick Guide
This paragraph is 100px high and min width is 400px This paragraph is 100px high and min width is
400px
CSS - Scrollbars
1
visible
2
hidden
The content of the nested element is simply cut off at the border of the containing element
and no scrollbars is visible.
3
scroll
The size of the containing element does not change, but the scrollbars are added to allow
the user to scroll to see the content.
4
auto
The purpose is the same as scroll, but the scrollbar will be shown only if the content does
overflow.
Here is an example −
Live Demo
<html>
<head>
<style type = "text/css">
.scroll {
display:block;
border: 1px solid red;
padding:5px;
margin-top:5px;
width:300px;
height:50px;
overflow:scroll;
}
.auto {
display:block;
https://www.tutorialspoint.com/css/css_quick_guide.htm 69/160
5/27/2019 CSS Quick Guide
border: 1px solid red;
padding:5px;
margin-top:5px;
width:300px;
height:50px;
overflow:auto;
}
</style>
</head>
<body>
<p>Example of scroll value:</p>
<div class = "scroll">
I am going to keep lot of content here just to show you how
scrollbars works if there is an overflow in an element box.
This provides your horizontal as well as vertical scrollbars.
</div>
<br />
CSS - Visibility
1
visible
2
hidden
https://www.tutorialspoint.com/css/css_quick_guide.htm 70/160
5/27/2019 CSS Quick Guide
The box and its content are made invisible, although they still affect the layout of the
page.
3
collapse
This is for use only with dynamic table columns and row effects.
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<p>
This paragraph should be visible in normal way.
</p>
CSS - Positioning
Move Up - Use a negative value for top.
Move Down - Use a positive value for top.
NOTE − You can use bottom or right values as well in the same way as top and left.
<body>
<div style = "position:relative; left:80px; top:2px; background-color:yellow;">
This div has relative positioning.
</div>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 71/160
5/27/2019 CSS Quick Guide
Absolute Positioning
An element with position: absolute is positioned at the specified coordinates relative to
your screen top-left corner.
You can use two values top and left along with the position property to move an HTML
element anywhere in the HTML document.
NOTE − You can use bottom or right values as well in the same way as top and left.
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<div style = "position:absolute; left:80px; top:20px; background-color:yellow;">
This div has absolute positioning.
</div>
</body>
</html>
Fixed Positioning
Fixed positioning allows you to fix the position of an element to a particular spot on the
page, regardless of scrolling. Specified coordinates will be relative to the browser window.
You can use two values top and left along with the position property to move an HTML
element anywhere in the HTML document.
NOTE − You can use bottom or right values as well in the same way as top and left.
https://www.tutorialspoint.com/css/css_quick_guide.htm 72/160
5/27/2019 CSS Quick Guide
Here is an example −
Live Demo
<html>
<head>
</head>
<body>
<div style = "position:fixed; left:80px; top:20px; background-color:yellow;">
This div has fixed positioning.
</div>
</body>
</html>
CSS - Layers
<body> <div style = "background-color:red; width:300px; height:100px; position:relative;
top:10px; left:80px; z-index:2"> </div> <div style = "background-color:yellow; width:300px;
height:100px; position:relative; top:-60px; left:35px; z-index:1;"> </div> <div style =
"background-color:green; width:300px; height:100px; position:relative; top:-220px; left:120px;
z-index:3;"> </div> </body> </html>
It will produce the following result −
1 :link
https://www.tutorialspoint.com/css/css_quick_guide.htm 73/160
5/27/2019 CSS Quick Guide
2 :visited
3 :hover
Use this class to add special style to an element when you mouse over it.
4 :active
5 :focus
Use this class to add special style to an element while the element has focus.
6 :first-child
Use this class to add special style to an element that is the first child of some
other element.
7 :lang
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 are different from CSS classes but they can be combined.
<body>
<a href = "">Black Link</a>
</body>
</html>
Black Link
<body>
<a href = "">Click this link</a>
</body>
</html>
This will produce following link. Once you will click this link, it will change its color to
green.
<body>
<a href = "">Bring Mouse Here</a>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 75/160
5/27/2019 CSS Quick Guide
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.
<body>
<a href = "">Click This Link</a>
</body>
</html>
It will produce the following link. When a user clicks it, the color changes to pink.
<body>
<a href = "">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 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.
For example, to indent the first paragraph of all <div> elements, you could use this
definition −
Live Demo
<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>
Heading
The first paragraph inside the div. This paragraph will not be effected.
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
https://www.tutorialspoint.com/css/css_quick_guide.htm 77/160
5/27/2019 CSS Quick Guide
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 −
Live Demo
<html>
<head>
<style type = "text/css">
<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.
1 :first-line
Use this element to add special styles to the first line of the text in a selector.
2 :first-letter
Use this element to add special style to the first letter of the text in a selector.
3 :before
4 :after
https://www.tutorialspoint.com/css/css_quick_guide.htm 78/160
5/27/2019 CSS Quick Guide
<body>
<p class = "noline">
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>
This line would not have any underline because this belongs to nline class.
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.
<body>
<p class = "normal">
https://www.tutorialspoint.com/css/css_quick_guide.htm 79/160
5/27/2019 CSS Quick Guide
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>
F irst character of this paragraph will be normal and will have font size 10 px;
T he first character of this paragraph will be 5em big and in red color 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.
<body>
<p> This line will be preceded by a bullet.</p>
<p> This line will be preceded by a bullet.</p>
<p> This line will be preceded by a bullet.</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 80/160
5/27/2019 CSS Quick Guide
<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>
CSS - @ Rules
The @import rule
The @import rule allows you to import styles from another style sheet. It should appear
right at the start of the style sheet before any of the rules, and its value is a URL.
The significance of the @import rule is that it allows you to develop your style sheets with
a modular approach. You can create various style sheets and then include them wherever
you need them.
https://www.tutorialspoint.com/css/css_quick_guide.htm 81/160
5/27/2019 CSS Quick Guide
The @charset rule must be written right at the beginning of the style sheet without even a
space before it. The value is held in quotes and should be one of the standard character-
sets. For example −
In general, @font-face is extremely complicated, and its use is not recommended for any
except those who are expert in font metrics.
Here is an example −
https://www.tutorialspoint.com/css/css_quick_guide.htm 82/160
5/27/2019 CSS Quick Guide
The !important rule provides a way to make your CSS cascade. It also includes the rules
that are to be applied always. A rule having a !important property will always be applied,
no matter where that rule appears in the CSS document.
For example, in the following style sheet, the paragraph text will be black, even though the
first style property applied is red:
So, if you wanted to make sure that a property always applied, you would add the
!important property to the tag. So, to make the paragraph text always red, you should
write it as follows −
Live Demo
<html>
<head>
<style type = "text/css">
p { color: #ff0000 !important; }
p { color: #000000; }
</style>
</head>
<body>
<p>Tutorialspoint.com</p>
</body>
</html>
Here you have made p { color: #ff0000 !important; } mandatory, now this rule will always
apply even you have defined another rule p { color: #000000; }
Tutorialspoint.com
2
finishopacity
3
style
https://www.tutorialspoint.com/css/css_quick_guide.htm 83/160
5/27/2019 CSS Quick Guide
0 = uniform
1 = linear
2 = radial
3 = rectangular
4
startX
5
startY
6
finishX
7
finishY
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 84/160
5/27/2019 CSS Quick Guide
Image Example:
Text Example:
CSS Tutorials
Motion Blur
Motion Blur is used to create blurred pictures or text with the direction and strength. The
following parameters can be used in this filter −
1 add
True or false. If true, the image is added to the blurred image; and if false, the
image is not added to the blurred image.
2 direction
0 = Top
45 = Top right
90 = Right
180 = Bottom
270 = Left
3 strength
https://www.tutorialspoint.com/css/css_quick_guide.htm 85/160
5/27/2019 CSS Quick Guide
The number of pixels the blur will extend. The default is 5 pixels.
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
Image Example:
Text Example:
CSS Tutorials
Chroma Filter
Chroma Filter is used to make any particular color transparent and usually it is used with
images. You can use it with scrollbars also. The following parameter can be used in this
filter −
1 color
https://www.tutorialspoint.com/css/css_quick_guide.htm 86/160
5/27/2019 CSS Quick Guide
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
Image Example:
Text Example:
CSS Tutorials
Drop Shadow Effect
Drop Shadow is used to create a shadow of your object at the specified X (horizontal) and
Y (vertical) offset and color.
https://www.tutorialspoint.com/css/css_quick_guide.htm 87/160
5/27/2019 CSS Quick Guide
1 color
2 offX
Number of pixels the drop shadow is offset from the visual object, along the x-
axis. Positive integers move the drop shadow to the right, negative integers
move the drop shadow to the left.
3 offY
Number of pixels the drop shadow is offset from the visual object, along the y-
axis. Positive integers move the drop shadow down, negative integers move the
drop shadow up.
4 positive
If true, all opaque pixels of the object have a dropshadow. If false, all
transparent pixels have a dropshadow. The default is true.
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 88/160
5/27/2019 CSS Quick Guide
Image Example:
Text Example:
Flip Effect
Flip effect is used to create a mirror image of the object. The following parameters can be
used in this filter −
1 FlipH
2 FlipV
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
</body>
</html>
Image Example:
Text Example:
CSS Tutorials
Glow Effect
Glow effect is used to create a glow around the object. If it is a transparent image, then
glow is created around the opaque pixels of it. The following parameters can be used in
this filter −
1 color
2 strength
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
Image Example:
Text Example:
CSS Tutorials
Grayscale Effect
Grayscale effect is used to convert the colors of the object to 256 shades of gray. The
following parameter is used in this filter −
1 grayscale
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 91/160
5/27/2019 CSS Quick Guide
<p>Text Example:</p>
Image Example:
Text Example:
Invert Effect
Invert effect is used to map the colors of the object to their opposite values in the color
spectrum, i.e., to create a negative image. The following parameter is used in this filter −
1 Invert
Maps the colors of the object to their opposite value in the color spectrum.
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 92/160
5/27/2019 CSS Quick Guide
Image Example:
Text Example:
Mask Effect
Mask effect is used to turn transparent pixels to a specified color and makes opaque pixels
transparent. The following parameter is used in this filter −
1 color
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 93/160
5/27/2019 CSS Quick Guide
font-size: 30pt;
font-family: Arial Black;
color: red;
filter: Mask(Color=#00FF00)">CSS Tutorials
</div>
</body>
</html>
Image Example:
Text Example:
CSS Tutorials
Shadow Filter
Shadow filter is used to create an attenuated shadow in the direction and color specified.
This is a filter that lies in between Dropshadow and Glow. The following parameters can be
used in this filter −
1 color
2 direction
0 = Top
45 = Top right
90 = Right
180 = Bottom
https://www.tutorialspoint.com/css/css_quick_guide.htm 94/160
5/27/2019 CSS Quick Guide
270 = Left
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
Image Example:
Text Example:
CSS Tutorials
Wave Effect
Wave effect is used to give the object a sine wave distortion to make it look wavy. The
following parameters can be used in this filter −
https://www.tutorialspoint.com/css/css_quick_guide.htm 95/160
5/27/2019 CSS Quick Guide
1 add
A value of 1 adds the original image to the waved image, 0 does not.
2 freq
3 light
4 phase
5 strength
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 96/160
5/27/2019 CSS Quick Guide
Image Example:
Text Example:
CSS Tutorials
X-Ray Effect
X-Ray effect grayscales and flattens the color depth. The following parameter is used in
this filter:
1 xray
Example
Live Demo
<html>
<head>
</head>
<body>
<p>Image Example:</p>
<p>Text Example:</p>
https://www.tutorialspoint.com/css/css_quick_guide.htm 97/160
5/27/2019 CSS Quick Guide
Image Example:
Text Example:
CSS Tutorials
CSS - Media Types
Given below is an example −
@media screen {
body { font-size: 12pt }
}
@media screen, print {
body { line-height: 1.2 }
}
-->
</style>
Following is an example −
<body>
<p>the body...
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 98/160
5/27/2019 CSS Quick Guide
-->
</style>
1 all
2 aural
3 braille
4 embossed
5 handheld
6 print
Intended for paged, opaque material and for documents viewed on screen in
print preview mode. Please consult the section on paged media.
7 projection
8 screen
https://www.tutorialspoint.com/css/css_quick_guide.htm 99/160
5/27/2019 CSS Quick Guide
9 tty
10 tv
The page area − The page area includes the boxes laid out on that page. The
edges of the page area act as the initial containing block for layout that occurs
between page breaks.
You can specify the dimensions, orientation, margins, etc., of a page box within an @page
rule. The dimensions of the page box are set with the 'size' property. The dimensions of
the page area are the dimensions of the page box minus the margin area.
For example, the following @page rule sets the page box size to 8.5 × 11 inches and
creates '2cm' margin on all sides between the page box edge and the page area −
You can use the margin, margin-top, margin-bottom, margin-left, and margin-right
properties within the @page rule to set margins for your page.
Finally, the marks property is used within the @page rule to create crop and registration
marks outside the page box on the target sheet. By default, no marks are printed. You
may use one or both of the crop and cross keywords to create crop marks and registration
marks, respectively, on the target print page.
https://www.tutorialspoint.com/css/css_quick_guide.htm 100/160
5/27/2019 CSS Quick Guide
auto − The page box will be set to the size and orientation of the target sheet.
landscape − Overrides the target's orientation. The page box is the same size as
the target, and the longer sides are horizontal.
portrait − Overrides the target's orientation. The page box is the same size as the
target, and the shorter sides are horizontal.
length − Length values for the 'size' property create an absolute page box. If only
one length value is specified, it sets both the width and height of the page box.
Percentage values are not allowed for the 'size' property.
In the following example, the outer edges of the page box will align with the target. The
percentage value on the 'margin' property is relative to the target size so if the target
sheet dimensions are 21.0cm × 29.7cm (i.e., A4), the margins are 2.10cm and 2.97cm.
The following example sets the width of the page box to be 8.5 inches and the height to be
11 inches. The page box in this example requires a target sheet size of 8.5" × 11" or
larger.
Once you create a named page layout, you can use it in your document by adding the
page property to a style that is later applied to an element in your document. For example,
this style renders all the tables in your document on landscape pages −
https://www.tutorialspoint.com/css/css_quick_guide.htm 101/160
5/27/2019 CSS Quick Guide
Due to the above rule, while printing, if the browser encounters a <table> element in your
document and the current page layout is the default portrait layout, it starts a new page
and prints the table on a landscape page.
@page :right {
margin-left: 3cm;
margin-right: 4cm;
}
-->
</style>
You can specify the style for the first page of a document with the :first pseudo-class −
@page :first {
margin-top: 10cm /* Top margin on first page 10cm */
}
-->
</style>
Controlling Pagination
Unless you specify otherwise, page breaks occur only when the page format changes or
when the content overflows the current page box. To otherwise force or suppress page
breaks, use the page-break-before, page-break-after, and page-break-inside properties.
Both the page-break-before and page-break-after accept the auto, always, avoid, left, and
right keywords.
The keyword auto is the default, it lets the browser generate page breaks as needed. The
keyword always forces a page break before or after the element, while avoid suppresses a
page break immediately before or after the element. The left and right keywords force one
or two page breaks, so that the element is rendered on a left-hand or right-hand page.
Using pagination properties is quite straightforward. Suppose your document has level-1
headers start new chapters with level-2 headers to denote sections. You'd like each
https://www.tutorialspoint.com/css/css_quick_guide.htm 102/160
5/27/2019 CSS Quick Guide
chapter to start on a new, right-hand page, but you don't want section headers to be split
across a page break from the subsequent content. You can achieve this using following
rule −
Use only the auto and avoid values with the page-break-inside property. If you prefer that
your tables not be broken across pages if possible, you would write the rule −
The orphans property specifies the minimum number of lines of a paragraph that
must be left at the bottom of a page.
The widows property specifies the minimum number of lines of a paragraph that
must be left at the top of a page.
Here is the example to create 4 lines at the bottom and 3 lines at the top of each page −
https://www.tutorialspoint.com/css/css_quick_guide.htm 103/160
5/27/2019 CSS Quick Guide
The CSS properties also allow you to vary the quality of synthesized speech (voice type,
frequency, inflection, etc.).
Here is an example −
<html>
<head>
<style type = "text/css">
h1, h2, h3, h4, h5, h6 {
voice-family: paul;
stress: 20;
richness: 90;
cue-before: url("../audio/pop.au");
}
p {
azimuth:center-right;
}
</style>
</head>
<body>
<h1>Tutorialspoint.com</h1>
<h2>Tutorialspoint.com</h2>
<h3>Tutorialspoint.com</h3>
<h4>Tutorialspoint.com</h4>
<h5>Tutorialspoint.com</h5>
<h6>Tutorialspoint.com</h6>
<p>Tutorialspoint.com</p>
</body>
</html>
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
It will direct the speech synthesizer to speak headers in a voice (a kind of audio font)
called "paul", on a flat tone, but in a very rich voice. Before speaking the headers, a sound
sample will be played from the given URL.
https://www.tutorialspoint.com/css/css_quick_guide.htm 104/160
5/27/2019 CSS Quick Guide
Paragraphs with class ‘heidi’ will appear to come from front left (if the sound system is
capable of spatial audio), and paragraphs of class ‘peter’ from the right.
The azimuth property sets, where the sound should come from horizontally.
The elevation property sets, where the sound should come from vertically.
The pitch specifies the average pitch (a frequency) of the speaking voice.
The speak specifies whether text will be rendered aurally and if so, in what
manner.
The stress specifies the height of "local peaks" in the intonation contour of a
voice.
https://www.tutorialspoint.com/css/css_quick_guide.htm 105/160
5/27/2019 CSS Quick Guide
The azimuth property sets where the sound should come from horizontally. The possible
values are listed below −
leftwards − Moves the sound to the left and relative to the current angle. More
precisely, subtracts 20 degrees.
rightwards − Moves the sound to the right, relative to the current angle. More
precisely, adds 20 degrees.
Here is an example −
angle − Specifies the elevation as an angle, between -90deg and 90deg. 0deg
means on the forward horizon, which loosely means level with the listener. 90deg
means directly overhead and -90deg means directly below.
https://www.tutorialspoint.com/css/css_quick_guide.htm 106/160
5/27/2019 CSS Quick Guide
Here is an example −
Here is an example −
Here is an example −
h1 {cue-before: url("pop.au"); }
-->
</style>
time − Expresses the pause in absolute time units (seconds and milliseconds).
percentage − Refers to the inverse of the value of the speech-rate property. For
example, if the speech-rate is 120 words per minute (i.e. a word takes half a
second, or 500ms), then a pause-after of 100% means a pause of 500 ms and a
pause-after of 20% means 100ms.
time − Expresses the pause in absolute time units (seconds and milliseconds).
percentage − Refers to the inverse of the value of the speech-rate property. For
example, if the speech-rate is 120 words per minute (i.e. a word takes half a
second, or 500ms), then a pause-before of 100% means a pause of 500 ms and a
pause-before of 20% means 100ms.
https://www.tutorialspoint.com/css/css_quick_guide.htm 108/160
5/27/2019 CSS Quick Guide
Here is an example −
frequency − Specifies the average pitch of the speaking voice in hertz (Hz).
x-low, low, medium, high, x-high − These values do not map to absolute
frequencies since these values depend on the voice family.
number − A value between '0' and '100'. A pitch range of '0' produces a flat,
monotonic voice. A pitch range of 50 produces normal inflection. Pitch ranges
greater than 50 produce animated voices.
URI − The sound designated by this <uri> is played as a background while the
element's content is spoken.
mix − When present, this keyword means that the sound inherited from the
parent element's play-during property continues to play and the sound designated
by the uri is mixed with it. If mix is not specified, the element's background sound
replaces the parent's.
https://www.tutorialspoint.com/css/css_quick_guide.htm 109/160
5/27/2019 CSS Quick Guide
repeat − When present, this keyword means that the sound will repeat if it is too
short to fill the entire duration of the element. Otherwise, the sound plays once
and then stops.
Here is an example −
number − A value between '0' and '100'. The higher the value, the more the voice
will carry. A lower value will produce a soft, mellifluous voice.
none − Suppresses aural rendering so that the element requires no time to render.
Note the difference between an element whose 'volume' property has a value of 'silent'
and an element whose 'speak' property has the value 'none'. The former takes up the
same time as if it had been spoken, including any pause before and after the element, but
no sound is generated. The latter requires no time and is not rendered.
https://www.tutorialspoint.com/css/css_quick_guide.htm 110/160
5/27/2019 CSS Quick Guide
digits − Speak the numeral as individual digits. Thus, "237" is spoken "Two Three
Seven".
continuous − Speak the numeral as a full number. Thus, "237" is spoken "Two
hundred thirty seven". Word representations are language-dependent.
slower − Subtracts 40 words per minutes from the current speech rate.
number − A value between '0' and '100'. The meaning of values depends on the
language being spoken. For example, a level of '50' for a standard, English-
speaking male voice (average pitch = 122Hz), speaking with normal intonation and
emphasis would have a different meaning than '50' for an Italian voice.
https://www.tutorialspoint.com/css/css_quick_guide.htm 111/160
5/27/2019 CSS Quick Guide
generic-voice − Values are voice families. Possible values are 'male', 'female',
and 'child'.
Here is an example −
numbers − Any number between '0' and '100'. '0' represents the minimum
audible volume level and 100 corresponds to the maximum comfortable level.
percentage − These values are calculated relative to the inherited value, and are
then clipped to the range '0' to '100'.
silent − No sound at all. The value '0' does not mean the same as 'silent'.
Here is an example −
CSS - Layouts
CSS is pivotal to the future of Web documents and will be supported by most
browsers.
CSS is more exact than tables, allowing your document to be viewed as you
intended, regardless of the browser window.
Keeping track of nested tables can be a real pain. CSS rules tend to be well
organized, easily read, and easily changed.
Finally, we would suggest you to use whichever technology makes sense to you and use
what you know or what presents your documents in the best way.
CSS also provides table-layout property to make your tables load much faster. Following is
an example −
You will notice the benefits more on large tables. With traditional HTML, the browser had to
calculate every cell before finally rendering the table. When you set the table-layout
algorithm to fixed, however, it only needs to look at the first row before rendering the
whole table. It means your table will need to have fixed column widths and row heights.
https://www.tutorialspoint.com/css/css_quick_guide.htm 113/160
5/27/2019 CSS Quick Guide
padding:0;
background:#FFF;
}
-->
</style>
Now, we will define a column with yellow color and later, we will attach this rule to a <div>
−
Upto this point, we will have a document with yellow body, so let us now define another
division inside level0 −
Now, we will nest one more division inside level1, and we will change just background
color −
Finally, we will use the same technique, nest a level3 division inside level2 to get the visual
layout for the right column −
https://www.tutorialspoint.com/css/css_quick_guide.htm 114/160
5/27/2019 CSS Quick Guide
}
-->
</style>
#level0 {background:#FC0;}
#level1 {
margin-left:143px;
padding-left:9px;
background:#FFF;
}
#level2 {background:#FFF3AC;}
#level3 {
margin-right:143px;
padding-right:9px;
background:#FFF;
}
#main {background:#CCC;}
</style>
<body>
<div id = "level0">
<div id = "level1">
<div id = "level2">
<div id = "level3">
<div id = "main">
Final Content goes here...
</div>
</div>
</div>
</div>
</div>
</body>
Similarly, you can add a top navigation bar or an ad bar at the top of the page.
CSS - Validations
W3C CSS Validator (World Wide Web Consortium), This validator checks your css by either file
upload, direct input, or using URI - one page at a time. This validator helps you to locate all the
errors in your CSS.
https://www.tutorialspoint.com/css/css_quick_guide.htm 115/160
5/27/2019 CSS Quick Guide
The WDG CSS check validator, lets you validate your css by direct input, file upload, and using
URI. Errors will be listed by line and column numbers if you have any. Errors usually come with
links to explain the reason of error.
A CSS validator checks your Cascading Style Sheets to make sure that they comply with
the CSS standards set by the W3 Consortium. There are a few validators which will also
tell you which CSS features are supported by which browsers (since not all browsers are
equal in their CSS implementation).
Professionalism: As a web developer, your code should not raise errors while seen
by the visitors.
CSS3 - Tutorial
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
Text Effects
2D Transformations
3D Transformations
Animations
User Interface
https://www.tutorialspoint.com/css/css_quick_guide.htm 116/160
5/27/2019 CSS Quick Guide
1 border-radius
2 border-top-left-radius
Use this element for setting the boarder of top left corner
3 border-top-right-radius
Use this element for setting the boarder of top right corner
4 border-bottom-right-radius
Use this element for setting the boarder of bottom right corner
5 border-bottom-left-radius
Use this element for setting the boarder of bottom left corner
Example
This property can have three values. The following example uses both the values −
Live Demo
<html>
<head>
<style>
#rcorners1 {
border-radius: 25px;
background: #8AC007;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners2 {
border-radius: 25px;
border: 2px solid #8AC007;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners3 {
border-radius: 25px;
background: url(/https/www.scribd.com/css/images/logo.png);
background-position: left top;
background-repeat: repeat;
padding: 20px;
width: 200px;
height: 150px;
}
</style>
</head>
https://www.tutorialspoint.com/css/css_quick_guide.htm 117/160
5/27/2019 CSS Quick Guide
<body>
<p id = "rcorners1">Rounded corners!</p>
<p id = "rcorners2">Rounded corners!</p>
<p id = "rcorners3">Rounded corners!</p>
</body>
</html>
Rounded corners!
Rounded corners!
Rounded corners!
https://www.tutorialspoint.com/css/css_quick_guide.htm 118/160
5/27/2019 CSS Quick Guide
<body>
<p id = "rcorners1"></p>
<p id = "rcorners2"></p>
<p id = "rcorners3"></p>
</body>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 119/160
5/27/2019 CSS Quick Guide
1 border-image-source
2 border-image-slice
3 border-image-width
4 border-image-repeat
Example
https://www.tutorialspoint.com/css/css_quick_guide.htm 120/160
5/27/2019 CSS Quick Guide
Following is the example which demonstrates to set image as a border for elements.
Live Demo
<html>
<head>
<style>
#borderimg1 {
border: 10px solid transparent;
padding: 15px;
border-image-source: url(/https/www.scribd.com/css/images/border.png);
border-image-repeat: round;
border-image-slice: 30;
border-image-width: 10px;
}
#borderimg2 {
border: 10px solid transparent;
padding: 15px;
border-image-source: url(/https/www.scribd.com/css/images/border.png);
border-image-repeat: round;
border-image-slice: 30;
border-image-width: 20px;
}
#borderimg3 {
border: 10px solid transparent;
padding: 15px;
border-image-source: url(/https/www.scribd.com/css/images/border.png);
border-image-repeat: round;
border-image-slice: 30;
border-image-width: 30px;
}
</style>
</head>
<body>
<p id = "borderimg1">This is image boarder example.</p>
<p id = "borderimg2">This is image boarder example.</p>
<p id = "borderimg3">This is image boarder example.</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 121/160
5/27/2019 CSS Quick Guide
1 background
2 background-clip
3 background-image
4 background-origin
5 background-size
Example
Following is the example which demonstrate the multi background images.
Live Demo
<html>
<head>
<style>
#multibackground {
background-image: url(/https/www.scribd.com/css/images/logo.png), url(/https/www.scribd.com/css/images/border.png);
background-position: left top, left top;
background-repeat: no-repeat, repeat;
padding: 75px;
}
</style>
</head>
<body>
<div id = "multibackground">
<h1>www.tutorialspoint.com</h1>
<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
https://www.tutorialspoint.com/css/css_quick_guide.htm 122/160
5/27/2019 CSS Quick Guide
skills at their own pace from the comforts of their drawing rooms.
The journey commenced with a single tutorial on HTML in 2006 and elated
by the response it generated, we worked our way to adding fresh tutorials
to our repository which now proudly flaunts a wealth of tutorials and
allied articles on topics ranging from programming languages to web designing
to academics and much more..
</p>
</div>
</body>
</html>
www.tutorialspoint.com
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. The journey commenced with a single
tutorial on HTML in 2006 and elated by the response it generated, we worked our
way to adding fresh tutorials to our repository which now proudly flaunts a wealth
of tutorials and allied articles on topics ranging from programming languages to
web designing to academics and much more..
#multibackground {
background: url(/https/www.scribd.com/css/imalges/logo.png) left top no-repeat, url(/https/www.scribd.com/css/images/boarder.png) right
background-size: 50px, 130px, auto;
}
As shown above an example, each image is having specific sizes as 50px, 130px and auto
size.
CSS3 - Colors
https://www.tutorialspoint.com/css/css_quick_guide.htm 123/160
5/27/2019 CSS Quick Guide
HSL stands for hue, 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 −
HSLA stands for hue, saturation, lightness and alpha. Alpha value specifies the opacity
as shown RGBA. A Sample syntax of HSLA as shown below −
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;}
<body>
<p>RGBA colors:</p>
<p id = "p1">Red</p>
<p id = "p2">Green</p>
<p id = "p3">Blue</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 124/160
5/27/2019 CSS Quick Guide
RGBA colors:
Red
Green
Blue
<body>
<p>HSL colors:</p>
<p id = "g1">Green</p>
<p id = "g2">Normal Green</p>
<p id = "g3">Dark Green</p>
</body>
</html>
HSL colors:
Green
Normal Green
Dark Green
<body>
<p>HSLA colors:</p>
<p id = "d1">Less opacity green</p>
<p id = "d2">Green</p>
<p id = "d3">Green</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 125/160
5/27/2019 CSS Quick Guide
HSLA colors:
Green
Green
<body>
<p>HSLA colors:</p>
<p id = "m1">Red</p>
<p id = "m2">Green</p>
<p id = "m3">Blue</p>
</body>
</html>
HSLA colors:
Red
Green
Blue
CSS3 - Gradients
Linear gradients
Linear gradients are used to arrange two or more colors in linear formats like top to
bottom.
Top to bottom
<html> Live Demo
<head>
<style>
#grad1 {
https://www.tutorialspoint.com/css/css_quick_guide.htm 126/160
5/27/2019 CSS Quick Guide
height: 100px;
background: -webkit-linear-gradient(pink,green);
background: -o-linear-gradient(pink,green);
background: -moz-linear-gradient(pink,green);
background: linear-gradient(pink,green);
}
</style>
</head>
<body>
<div id = "grad1"></div>
</body>
</html>
Left to right
<html> Live Demo
<head>
<style>
#grad1 {
height: 100px;
background: -webkit-linear-gradient(left, red , blue);
background: -o-linear-gradient(right, red, blue);
background: -moz-linear-gradient(right, red, blue);
background: linear-gradient(to right, red , blue);
}
</style>
</head>
<body>
<div id = "grad1"></div>
</body>
</html>
Diagonal
Diagonal starts at top left and right button.
https://www.tutorialspoint.com/css/css_quick_guide.htm 127/160
5/27/2019 CSS Quick Guide
<body>
<div id = "grad1"></div>
</body>
</html>
Multi color
<html> Live Demo
<head>
<style>
#grad2 {
height: 100px;
background: -webkit-linear-gradient(red, orange, yellow, red, blue, green,pink);
background: -o-linear-gradient(red, orange, yellow, red, blue, green,pink);
background: -moz-linear-gradient(red, orange, yellow, red, blue, green,pink);
background: linear-gradient(red, orange, yellow, red, blue, green,pink);
}
</style>
</head>
<body>
<div id = "grad2"></div>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 128/160
5/27/2019 CSS Quick Guide
<body>
<div id = "grad1"></div>
</body>
</html>
<body>
<div id = "grad1"></div>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 129/160
5/27/2019 CSS Quick Guide
CSS3 - Shadow
<html>
<head>
<style>
h1 {
text-shadow: 2px 2px;
}
h2 {
text-shadow: 2px 2px red;
}
h3 {
text-shadow: 2px 2px 5px red;
}
h4 {
color: white;
text-shadow: 2px 2px 4px #000000;
}
h5 {
text-shadow: 0 0 3px #FF0000;
}
h6 {
text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
}
p {
color: white;
text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
}
</style>
</head>
<body>
<h1>Tutorialspoint.com</h1>
<h2>Tutorialspoint.com</h2>
<h3>Tutorialspoint.com</h3>
<h4>Tutorialspoint.com</h4>
<h5>Tutorialspoint.com</h5>
<h6>Tutorialspoint.com</h6>
<p>Tutorialspoint.com</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 130/160
5/27/2019 CSS Quick Guide
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
Tutorialspoint.com
box shadow
Used to add shadow effects to elements, Following is the example to add shadow effects to
element.
Live Demo
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
padding: 15px;
background-color: red;
box-shadow: 10px 10px;
}
</style>
</head>
<body>
<div>This is a div element with a box-shadow</div>
</body>
</html>
CSS3 - Text
https://www.tutorialspoint.com/css/css_quick_guide.htm 131/160
5/27/2019 CSS Quick Guide
2
text-emphasis
3
text-overflow
used to determines how overflowed content that is not displayed is signaled to users
4
word-break
5
word-wrap
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 −
Live Demo
<html>
<head>
<style>
p.text1 {
white-space: nowrap;
width: 500px;
border: 1px solid #000000;
overflow: hidden;
text-overflow: clip;
}
p.text2 {
white-space: nowrap;
width: 500px;
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
https://www.tutorialspoint.com/css/css_quick_guide.htm 132/160
5/27/2019 CSS Quick Guide
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>
<b>Text overflow:ellipsis</b>
</body>
</html>
Original Text:
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.
Text overflow:clip
Tutorials Point originated from the idea that there exists a class of readers who
Text overflow:ellipsis
Tutorials Point originated from the idea that there exists a class of readers …
word-break: break-all;
}
</style>
</head>
<body>
</body>
</html>
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.
https://www.tutorialspoint.com/css/css_quick_guide.htm 134/160
5/27/2019 CSS Quick Guide
p {
word-wrap: break-word;
}
TrueType is an outline font standard developed by Apple and Microsoft in the late 1980s, It
became most common fonts for both windows and MAC operating systems.
2
OpenType Fonts (OTF)
3
The Web Open Font Format (WOFF)
WOFF is used for develop web page and developed in the year of 2009. Now it is using by
W3C recommendation.
4
SVG Fonts/Shapes
SVG allow SVG fonts within SVG documentation. We can also apply CSS to SVG with font
face property.
5
Embedded OpenType Fonts (EOT)
EOT is used to develop the web pages and it has embedded in webpages so no need to
allow 3rd party fonts
https://www.tutorialspoint.com/css/css_quick_guide.htm 135/160
5/27/2019 CSS Quick Guide
</Style>
</head>
<body>
<div>This is the example of font face with CSS3.</div>
<p><b>Original Text :</b>This is the example of font face with CSS3.</p>
</body>
</html>
Fonts description
The following list contained all the fonts description which are placed in the @font-face rule
−
1 font-family
2 src
3 font-stretch
4 font-style
5 font-weight
CSS3 - 2d Transforms
1
matrix(n,n,n,n,n,n)
2
translate(x,y)
3
translateX(n)
4
translateY(n)
5
scale(x,y)
6
scaleX(n)
7
scaleY(n)
8
rotate(angle)
9
skewX(angle)
10
skewY(angle)
The following examples are shown the sample of all above properties.
Rotate 20 degrees
Box rotation with 20 degrees angle as shown below −
Live Demo
<html>
<head>
<style>
https://www.tutorialspoint.com/css/css_quick_guide.htm 137/160
5/27/2019 CSS Quick Guide
div {
width: 300px;
height: 100px;
background-color: pink;
border: 1px solid black;
}
div#myDiv {
/* IE 9 */
-ms-transform: rotate(20deg);
/* Safari */
-webkit-transform: rotate(20deg);
/* Standard syntax */
transform: rotate(20deg);
}
</style>
</head>
<body>
<div>
Tutorials point.com.
</div>
<div id = "myDiv">
Tutorials point.com
</div>
</body>
</html>
Tutorials point.com.
Tuto
rials
poin
t.co
m
https://www.tutorialspoint.com/css/css_quick_guide.htm 138/160
5/27/2019 CSS Quick Guide
height: 100px;
background-color: pink;
border: 1px solid black;
}
div#myDiv {
/* IE 9 */
-ms-transform: rotate(-20deg);
/* Safari */
-webkit-transform: rotate(-20deg);
/* Standard syntax */
transform: rotate(-20deg);
}
</style>
</head>
<body>
<div>
Tutorials point.com.
</div>
<div id = "myDiv">
Tutorials point.com
</div>
</body>
</html>
Tutorials point.com.
int.com
r ials po
Tuto
Skew X axis
Box rotation with skew x-axis as shown below −
Live Demo
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: pink;
https://www.tutorialspoint.com/css/css_quick_guide.htm 139/160
5/27/2019 CSS Quick Guide
/* Safari */
-webkit-transform: skewX(20deg);
/* Standard syntax */
transform: skewX(20deg);
}
</style>
</head>
<body>
<div>
Tutorials point.com.
</div>
<div id = "skewDiv">
Tutorials point.com
</div>
</body>
</html>
Tutorials point.com.
Tutorials point.com
Skew Y axis
Box rotation with skew y-axis as shown below −
Live Demo
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: pink;
border: 1px solid black;
}
div#skewDiv {
/* IE 9 */
-ms-transform: skewY(20deg);
https://www.tutorialspoint.com/css/css_quick_guide.htm 140/160
5/27/2019 CSS Quick Guide
/* Safari */
-webkit-transform: skewY(20deg);
/* Standard syntax */
transform: skewY(20deg);
}
</style>
</head>
<body>
<div>
Tutorials point.com.
</div>
<div id = "skewDiv">
Tutorials point.com
</div>
</body>
</html>
Tutorials point.com.
Tuto
r ials
poin
t.co
m
Matrix transform
Box rotation with Matrix transforms as shown below −
Live Demo
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: pink;
border: 1px solid black;
}
div#myDiv1 {
/* IE 9 */
-ms-transform: matrix(1, -0.3, 0, 1, 0, 0);
/* Safari */
https://www.tutorialspoint.com/css/css_quick_guide.htm 141/160
5/27/2019 CSS Quick Guide
/* Standard syntax */
transform: matrix(1, -0.3, 0, 1, 0, 0);
}
</style>
</head>
<body>
<div>
Tutorials point.com.
</div>
<div id = "myDiv1">
Tutorials point.com
</div>
</body>
</html>
Tutorials point.com.
om
s point.c
Tut orial
/* Safari */
-webkit-transform: matrix(1, 0, 0.5, 1, 150, 0);
/* Standard syntax */
transform: matrix(1, 0, 0.5, 1, 150, 0);
}
</style>
https://www.tutorialspoint.com/css/css_quick_guide.htm 142/160
5/27/2019 CSS Quick Guide
</head>
<body>
<div>
Tutorials point.com.
</div>
<div id = "myDiv2">
Tutorials point.com
</div>
</body>
</html>
Tutorials point.com.
Tutorials point.com
CSS3 - 3D Transforms
1
matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)
2
translate3d(x,y,z)
3
translateX(x)
4
translateY(y)
5
translateZ(z)
https://www.tutorialspoint.com/css/css_quick_guide.htm 143/160
5/27/2019 CSS Quick Guide
6
scaleX(x)
7
scaleY(y)
8
scaleY(y)
9
rotateX(angle)
10
rotateY(angle)
11
rotateZ(angle)
X-axis 3D transforms
The following an example shows the x-axis 3D transforms.
Live Demo
<html>
<head>
<style>
div {
width: 200px;
height: 100px;
background-color: pink;
border: 1px solid black;
}
div#myDiv {
-webkit-transform: rotateX(150deg);
/* Safari */
transform: rotateX(150deg);
/* Standard syntax */
}
</style>
</head>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 144/160
5/27/2019 CSS Quick Guide
<div>
tutorials point.com
</div>
<p>Rotate X-axis</p>
<div id = "myDiv">
tutorials point.com.
</div>
</body>
</html>
tutorials point.com
Rotate X-axis
tutorials point.com .
Y-axis 3D transforms
The following an example shows the y-axis 3D transforms −
Live Demo
<html>
<head>
<style>
div {
width: 200px;
height: 100px;
background-color: pink;
border: 1px solid black;
}
div#yDiv {
-webkit-transform: rotateY(150deg);
/* Safari */
transform: rotateY(150deg);
/* Standard syntax */
}
</style>
</head>
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 145/160
5/27/2019 CSS Quick Guide
<div>
tutorials point.com
</div>
<p>Rotate Y axis</p>
<div id = "yDiv">
tutorials point.com.
</div>
</body>
</html>
tutorials point.com
Rotate Y axis
. moc.tniop slairotut
Z-axis 3D transforms
The following an example shows the Z-axis 3D transforms −
Live Demo
<html>
<head>
<style>
div {
width: 200px;
height: 100px;
background-color: pink;
border: 1px solid black;
}
div#zDiv {
-webkit-transform: rotateZ(90deg);
/* Safari */
transform: rotateZ(90deg);
/* Standard syntax */
}
</style>
</head>
<body>
<div>
https://www.tutorialspoint.com/css/css_quick_guide.htm 146/160
5/27/2019 CSS Quick Guide
tutorials point.com
</div>
<p>rotate Z axis</p>
<div id = "zDiv">
tutorials point.com.
</div>
</body>
</html>
tutorialspoint.com
tutorials point.com .
rotate Z axis
CSS3 - Animation
} div { width: 100px; height: 100px; background-color: red; animation-name: animation;
animation-duration: 5s; }
The above example shows height, width, color, name and duration of animation with
keyframes syntax.
https://www.tutorialspoint.com/css/css_quick_guide.htm 147/160
5/27/2019 CSS Quick Guide
}
to {
margin-left:0%;
width:100%;
}
}
@-webkit-keyframes slidein {
from {
margin-left:100%;
width:300%
}
to {
margin-left:0%;
width:100%;
}
}
</style>
</head>
<body>
<h1>Tutorials Point</h1>
<p>this is an example of moving left animation .</p>
<button onclick = "myFunction()">Reload page</button>
<script>
function myFunction() {
location.reload();
}
</script>
</body>
</html>
Tutorials Point
this is an example of moving left animation .
Reload page
font-size:300%;
margin-left:25%;
width:150%;
}
to {
margin-left:0%;
width:100%;
}
}
@-webkit-keyframes slidein {
from {
margin-left:100%;
width:300%
}
75% {
font-size:300%;
margin-left:25%;
width:150%;
}
to {
margin-left:0%;
width:100%;
}
}
</style>
</head>
<body>
<h1>Tutorials Point</h1>
Tutorials Point
This is an example of animation left with an extra keyframe to make text changes.
Reload page
https://www.tutorialspoint.com/css/css_quick_guide.htm 149/160
5/27/2019 CSS Quick Guide
2
column-fill
3
column-gap
4
column-rule
5
rule-color
6
rule-style
7
rule-width
8
column-span
Example
Below example shows the arrangement of text as new paper structure.
Live Demo
<html>
<head>
<style>
.multi {
/* Column count property */
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
https://www.tutorialspoint.com/css/css_quick_guide.htm 150/160
5/27/2019 CSS Quick Guide
-moz-column-rule-style: solid;
column-rule-style: solid;
}
</style>
</head>
<body>
</body>
</html>
For suppose, if user wants to make text as new paper without line, we can do this by
removing style syntax as shown below −
.multi {
/* Column count property */
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
https://www.tutorialspoint.com/css/css_quick_guide.htm 151/160
5/27/2019 CSS Quick Guide
2
box-sizing
3
icon
4
resize
5
outline-offset
6
nav-down
Used to move down when you have pressed on down arrow button in keypad.
7
nav-left
Used to move left when you have pressed on left arrow button in keypad.
8
nav-right
Used to move right when you have pressed on right arrow button in keypad.
https://www.tutorialspoint.com/css/css_quick_guide.htm 152/160
5/27/2019 CSS Quick Guide
nav-up
horizontal
vertical
both
<body>
<div>TutorialsPoint.com</div>
</body>
</html>
TutorialsPoint.com
https://www.tutorialspoint.com/css/css_quick_guide.htm 153/160
5/27/2019 CSS Quick Guide
outline-offset: 15px;
}
</style>
</head>
<body>
<div>TutorialsPoint</div>
</body>
</html>
TutorialsPoint
<body>
<div class = "div1">TutorialsPoint.com</div><br />
<div class = "div2">TutorialsPoint.com</div>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 154/160
5/27/2019 CSS Quick Guide
TutorialsPoint.com
TutorialsPoint.com
Above image is having same width and height of two element but giving result is different,
cause second one is included padding property.
<body>
<div class = "div1">TutorialsPoint.com</div><br />
<div class = "div2">TutorialsPoint.com</div>
</body>
</html>
Above sample is having same height and width with box-sizing:border-box. here result
is shown below.
https://www.tutorialspoint.com/css/css_quick_guide.htm 155/160
5/27/2019 CSS Quick Guide
TutorialsPoint.com
TutorialsPoint.com
Above elements are having same height and width with box-sizing:border-box so result is
always same for both elements as shown above.
CSS - Responsive
<html> <head> <style> body { font: 600 14px/24px "Open Sans", "HelveticaNeue-Light",
"Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", Sans-Serif; } h1 {
color: #9799a7; font-size: 14px; font-weight: bold; margin-bottom: 6px; } .container:before,
.container:after { content: ""; display: table; } .container:after { clear: both; } .container {
background: #eaeaed; margin-bottom: 24px; *zoom: 1; } .container-75 { width: 75%; }
.container-50 { margin-bottom: 0; width: 50%; } .container, section, aside { border-radius: 6px;
} section, aside { background: #2db34a; color: #fff; margin: 1.858736059%; padding: 20px 0;
text-align: center; } section { float: left; width: 63.197026%; } aside { float: right; width:
29.3680297%; } </style> </head> <body> <h1>100% Wide Container</h1> <div class =
"container"> <section>Section</section> <aside>Aside</aside> </div> <h1>75% Wide
Container</h1> <div class = "container container-75"> <section>Section</section>
<aside>Aside</aside> </div> <h1>50% Wide Container</h1> <div class = "container
container-50"> <section>Section</section> <aside>Aside</aside> </div> </body> </html>
It will produce the following result −
https://www.tutorialspoint.com/css/css_quick_guide.htm 156/160
5/27/2019 CSS Quick Guide
Section Aside
Section Aside
Section Aside
Media queries
Media queries is for different style rules for different size devices such as mobiles,
desktops, etc.,
Live Demo
<html>
<head>
<style>
body {
background-color: lightpink;
}
@media screen and (max-width: 420px) {
body {
background-color: lightblue;
}
}
</style>
</head>
<body>
<p>
If screen size is less than 420px, then it will show lightblue
color, or else it will show light pink color
</p>
</body>
</html>
https://www.tutorialspoint.com/css/css_quick_guide.htm 157/160
5/27/2019 CSS Quick Guide
If screen size is less than 420px,then it will show lightblue color, or else it will show light pink color
<body>
https://www.tutorialspoint.com/css/css_quick_guide.htm 158/160
5/27/2019 CSS Quick Guide
</body>
</html>
Tutorials point
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.
Android
Android is an open source and Linux-based operating system for mobile devices such as smartphones and
tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other
companies.
CSS
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to simplify the
process of making web pages presentable.
Java
Java is a high-level programming language originally developed by Sun Microsystems and released in
1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
This tutorial gives a complete understanding of Java.
Advertisements
https://www.tutorialspoint.com/css/css_quick_guide.htm 159/160
5/27/2019 CSS Quick Guide
https://www.tutorialspoint.com/css/css_quick_guide.htm 160/160