CSS Commands
CSS Commands
CSS Examples
CSS Syntax
1) <!DOCTYPE html>
<html>
<head>
<style>
p{
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
Rezultati
Me too!
And me!
2) <!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
Rezultati
Hello World!
3) <!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
Rezultati
<html>
<head>
<style>
p.center {
text-align: center;
color: red;
</style>
</head>
<body>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: red;
</style>
</head>
<body>
<h1>Hello World!</h1>
<h2>Smaller heading!</h2>
<p>This is a paragraph.</p>
</body>
</html>
Rezultati
Hello World!
Smaller heading!
This is a paragraph.
CSS Backgrounds
1) <!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: lightblue;
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
Rezultati
Hello World!
2) <!DOCTYPE html>
<html>
<head>
<style>
h1 {
background-color: green;
div {
background-color: lightblue;
p{
background-color: yellow;
</style>
</head>
<body>
<div>
</div>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("paper.gif");
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
Rezultati
Hello World!
4) <!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("gradient_bg.png");
background-repeat: repeat-x;
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
Rezultati
Hello World!
5) <!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>Now the background image is only shown once, and positioned away from the
text.</p>
<p>In this example we have also added a margin on the right side, so the
background image will never disturb the text.</p>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
margin-right: 200px;
background-attachment: fixed;
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>If you do not see any scrollbars, try to resize the browser window.</p>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
body {
margin-right: 200px;
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>Now the background image is only shown once, and it is also positioned away
from the text.</p>
<p>In this example we have also added a margin on the right side, so that the
background image will not disturb the text.</p>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
body {
margin-left: 200px;
.center_div {
margin-left: auto;
margin-right: auto;
width: 90%;
background-color: #d0f0f6;
text-align: left;
padding: 8px;
</style>
</head>
<body>
<div class="center_div">
<h1>Hello World!</h1>
<p>This example contains some advanced CSS methods you may not have
learned yet. But, we will explain these methods in a later chapter in the
tutorial.</p>
</div>
</body>
</html>
Rezultati
CSS Borders
Set the width of the four borders
Set the width of the top border
Set the width of the bottom border
Set the width of the left border
Set the width of the right border
Set the style of the four borders
Set the style of the top border
Set the style of the bottom border
Set the style of the left border
Set the style of the right border
Set the color of the four borders
Set the color of the top border
Set the color of the bottom border
Set the color of the left border
Set the color of the right border
All the border properties in one declaration
Set different borders on each side
All the top border properties in one declaration
All the bottom border properties in one declaration
All the left border properties in one declaration
All the right border properties in one declaration
1) <!DOCTYPE html>
<html>
<head>
<style>
p.one {
border-style: solid;
border-width: 5px;
p.two {
border-style: solid;
border-width: medium;
p.three {
border-style: dotted;
border-width: 2px;
p.four {
border-style: dotted;
border-width: thick;
p.five {
border-style: double;
border-width: 15px;
p.six {
border-style: double;
border-width: thick;
p.seven {
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
border-top-width: 15px;
</style>
</head>
<body>
<p><b>Note:</b> The "border-top-width" property does not work if it is used
alone. Use the "border-style" property to set the borders first.</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
border-bottom-width: 15px;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
border-left-width: 15px;
</style>
</head>
<body>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
border-right-width: 15px;
</style>
</head>
<body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
p {border-style: solid;}
</style>
</head>
<body>
</body>
</html>
Rezultati
9) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
10) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
11) <!DOCTYPE html>
<html>
<head>
<style>
p.one {
border-style: solid;
border-color: #0000ff;
p.two {
border-style: solid;
}
p.three {
border-style: solid;
p.four {
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
12) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
border-top-color: #ff0000;
</style>
</head>
<body>
</html>
Rezultati
<html>
<head>
<style>
p{
border-style: solid;
border-bottom-color: #ff0000;
</style>
</head>
<body>
</body>
</html>
Rezultati
<html>
<head>
<style>
p{
border-style: solid;
border-left-color: #ff0000;
</style>
</head>
<body>
</body>
</html>
Rezultati
<html>
<head>
<style>
p{
border-style: solid;
border-right-color: #ff0000;
</style>
</head>
<body>
</body>
</html>
Rezultati
<html>
<head>
<style>
div {
</style>
</head>
<body>
</body>
</html>
Rezultati
17) <!DOCTYPE html>
<html>
<head>
<style>
p.one {
p.two {
p.three {
border-style: dotted solid;
p.four {
border-style: dotted;
</style>
</head>
<body>
</body>
</html>
Rezultati
18) <!DOCTYPE html>
<html>
<head>
<style>
p{
border-style: solid;
</style>
</head>
<body>
</html>
Rezultati
<html>
<head>
<style>
p{
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
<html>
<head>
<style>
p{
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
<html>
<head>
<style>
p{
border-style: solid;
</style>
</head>
<body>
</body>
</html>
Rezultati
CSS Margins
Specify different margins for each side of an element
Let the left margin be inherited from the parent element
The margin shorthand property
Set margin to auto to center the element within its container
1) <!DOCTYPE html>
<html>
<head>
<style>
p{
background-color: yellow;
p.ex {
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
</style>
</head>
<body>
<p class="ex">This paragraph has a top and bottom margin of 100px, a left margin
of 80px, and a right margin of 150px.</p>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
div.container {
margin-left: 100px;
p.one {
margin-left: inherit;
</style>
</head>
<body>
<div class="container">
<p class="one">This is a paragraph with an inherited left margin (from the div
element).</p>
</div>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
p{
background-color: yellow;
p.ex {
</style>
</head>
<body>
<p class="ex">This paragraph has a top and bottom margin of 100px, a left margin
of 80px, and a right margin of 150px.</p>
</body>
</html>
Rezultati
<html>
<head>
<style>
div {
width:300px;
margin: auto;
</style>
</head>
<body>
<p>You can set the margin property to auto to horizontally center the element
within its container.
The element will then take up the specified width, and the remaining space will be
split equally between the left and right margins:</p>
<div>
</div>
</body>
</html>
Rezultati
CSS Padding
1) <!DOCTYPE html>
<html>
<head>
<style>
p.padding {
padding-left: 2cm;
p.padding2 {
padding-left: 50%;
</style>
</head>
<body>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
p.padding {
padding-right: 2cm;
p.padding2 {
padding-right: 50%;
</style>
</head>
<body>
<p>This is a text with no right padding. This is a text with no right padding. This is
a text with no right padding.</p>
<p class="padding">This text has a right padding of 2 cm. This text has a right
padding of 2 cm. This text has a right padding of 2 cm.</p>
<p class="padding2">This text has a right padding of 50%. This text has a right
padding of 50%. This text has a right padding of 50%.</p>
</body>
</html>
Rezultati
This is a text with no right padding. This is a text with no right padding. This is a text
with no right padding.
This text has a right padding of 2 cm. This text has a right padding of 2 cm. This text
has a right padding of 2 cm.
This text has a right padding of 50%. This text has a right padding of 50%. This text
has a right padding of 50%.
3) <!DOCTYPE html>
<html>
<head>
<style>
p.padding {
padding-top: 2cm;
p.padding2 {
padding-top: 50%;
</style>
</head>
<body>
<p>This is a text with no top padding. This is a text with no top padding. This is a
text with no top padding.</p>
<p class="padding">This text has a top padding of 2 cm. This text has a top
padding of 2 cm. This text has a top padding of 2 cm.</p>
<p class="padding2">This text has a top padding of 50%. This text has a top
padding of 50%. This text has a top padding of 50%.</p>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
p.padding {
padding-bottom:2cm;
p.padding2 {
padding-bottom:50%;
</style>
</head>
<body>
<p>This is a text with no bottom padding. This is a text with no bottom padding.
This is a text with no bottom padding.</p>
<p class="padding">This text has a bottom padding of 2 cm. This text has a
bottom padding of 2 cm. This text has a bottom padding of 2 cm.</p>
<p class="padding2">This text has a bottom padding of 50%. This text has a
bottom padding of 50%. This text has a bottom padding of 50%.</p>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
p.ex1 {
padding: 2cm;
p.ex2 {
</style>
</head>
<body>
<p class="ex1">This text has equal padding on each side. The padding on each
side is 2cm.</p>
<p class="ex2">This text has a top and bottom padding of 0.5cm and a left and
right padding of 3cm.</p>
</body>
</html>
Rezultati
CSS Text
<html>
<head>
<style>
body {
color: blue;
h1 {
color: green;
</style>
</head>
<body>
<p>This is an ordinary paragraph. Notice that this text is blue. The default text
color for a page is defined in the body selector.</p>
</body>
</html>
Rezultati
This is heading 1
This is an ordinary paragraph. Notice that this text is blue. The default text color for a
page is defined in the body selector.
2) <!DOCTYPE html>
<html>
<head>
<style>
div {
padding: 10px;
width: 200px;
height: 200px;
text-align: justify;
</style>
</head>
<body>
<p>The text-align: justify; value stretches the lines so that each line has equal
width (like in newspapers and magazines).</p>
<div>
In my younger and more vulnerable years my father gave me some advice that I've
been turning over in my mind ever since. 'Whenever you feel like criticizing anyone,'
he told me, 'just remember that all the people in this world haven't had the
advantages that you've had.'
</div>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
a{
text-decoration: none;
</style>
</head>
<body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-decoration: overline;
h2 {
text-decoration: line-through;
h3 {
text-decoration: underline;
</style>
</head>
<body>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
p.uppercase {
text-transform: uppercase;
p.lowercase {
text-transform: lowercase;
}
p.capitalize {
text-transform: capitalize;
</style>
</head>
<body>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
p{
text-indent: 50px;
</style>
</head>
<body>
<p>In my younger and more vulnerable years my father gave me some advice that
I've been turning over in my mind ever since. 'Whenever you feel like criticizing
anyone,' he told me, 'just remember that all the people in this world haven't had the
advantages that you've had.'</p>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
h1 {
letter-spacing: 3px;
h2 {
letter-spacing: -3px;
</style>
</head>
<body>
</body>
</html>
Rezultati
This is heading 1
This is heading 2
8) <!DOCTYPE html>
<html>
<head>
<style>
p.small {
line-height: 0.7;
p.big {
line-height: 1.8;
</style>
</head>
<body>
<p>
</p>
<p class="small">
</p>
<p class="big">
</p>
</body>
</html>
Rezultati
9) <!DOCTYPE html>
<html>
<head>
<style>
div.ex1 {
direction: rtl;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
<html>
<head>
<style>
h1 {
word-spacing: 10px;
h2 {
word-spacing: -5px;
</style>
</head>
<body>
</body>
</html>
Rezultati
11) <!DOCTYPE html>
<html>
<head>
<style>
p{
white-space: nowrap;
</style>
</head>
<body>
<p>
</p>
</body>
</html>
Rezultati
This is some text. This is some text. This is some text. This is
some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some
text. This is some text.
<html>
<head>
<style>
img.top {
vertical-align: text-top;
}
img.bottom {
vertical-align: text-bottom;
</style>
</head>
<body>
</body>
</html>
Rezultati
CSS Fonts
1) <!DOCTYPE html>
<html>
<head>
<style>
p.serif {
p.sansserif {
</style>
</head>
<body>
<h1>CSS font-family</h1>
</body>
</html>
Rezultati
CSS font-family
This is a paragraph, shown in the Times New Roman font.
2) <!DOCTYPE html>
<html>
<head>
<style>
h1 {
font-size:250%;
h2 {
font-size:200%;
p{
font-size:100%;
</style>
</head>
<body>
<h1>This is heading 1</h1>
<p>This is a paragraph.</p>
</body>
</html>
Rezultati
This is heading 1
This is heading 2
This is a paragraph.
3) <!DOCTYPE html>
<html>
<head>
<style>
h1 {
font-size: 40px;
h2 {
font-size: 30px;
p{
font-size: 14px;
}
</style>
</head>
<body>
<p>This is a paragraph.</p>
</body>
</html>
Rezultati
This is heading 1
This is heading 2
This is a paragraph.
4) <!DOCTYPE html>
<html>
<head>
<style>
h1 {
h2 {
p{
</style>
</head>
<body>
<p>This is a paragraph.</p>
<p>Specifying the font-size in em allows all major browsers to resize the text.
Unfortunately, there is still a problem with older versions of IE. When resizing the
text, it becomes larger/smaller than it should.</p>
</body>
</html>
Rezultati
This is heading 1
This is heading 2
This is a paragraph.
Specifying the font-size in em allows all major browsers to resize the text. Unfortunately, there is still a
problem with older versions of IE. When resizing the text, it becomes larger/smaller than it should.
5) <!DOCTYPE html>
<html>
<head>
<style>
body {
font-size: 100%;
h1 {
font-size: 2.5em;
h2 {
font-size: 1.875em;
p{
font-size: 0.875em;
</style>
</head>
<body>
<p>This is a paragraph.</p>
<p>Specifying the font-size in percent and em displays the same size in all major
browsers, and allows all browsers to resize the text!</p>
</body>
</html>
Rezultati
This is heading 1
This is heading 2
This is a paragraph.
Specifying the font-size in percent and em displays the same size in all major browsers, and allows all
browsers to resize the text!
6) <!DOCTYPE html>
<html>
<head>
<style>
p.normal {
font-style: normal;
}
p.italic {
font-style: italic;
}
p.oblique {
font-style: oblique;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
p.small {
font-variant: small-caps;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
p.normal {
font-weight: normal;
p.light {
font-weight: lighter;
}
p.thick {
font-weight: bold;
p.thicker {
font-weight: 900;
</style>
</head>
<body>
</body>
</html>
Rezultati
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
9) <!DOCTYPE html>
<html>
<head>
<style>
p.ex1 {
p.ex2 {
</style>
</head>
<body>
</body>
</html>
Rezultati
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a
paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
CSS Icons
1) <!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<title>Bootstrap Icons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.cs
s">
</head>
<body class="container">
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<title>Google Icons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?
family=Material+Icons">
</head>
<body>
</body>
</html>
Rezultati
CSS Links
1) <!DOCTYPE html>
<html>
<head>
<style>
/* unvisited link */
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
}
/* selected link */
a:active {
color: blue;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
This is a link
Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to
be effective.
Note: a:active MUST come after a:hover in the CSS definition in order to be
effective.
2) <!DOCTYPE html>
<html>
<head>
<style>
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
This is a link
Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to
be effective.
Note: a:active MUST come after a:hover in the CSS definition in order to be
effective.
3) <!DOCTYPE html>
<html>
<head>
<style>
a:link {
background-color: yellow;
}
a:visited {
background-color: cyan;
}
a:hover {
background-color: lightgreen;
}
a:active {
background-color: hotpink;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
This is a link
Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to
be effective.
Note: a:active MUST come after a:hover in the CSS definition in order to be
effective.
4) <!DOCTYPE html>
<html>
<head>
<style>
a.one:link {color:#ff0000;}
a.one:visited {color:#0000ff;}
a.one:hover {color:#ffcc00;}
a.two:link {color:#ff0000;}
a.two:visited {color:#0000ff;}
a.two:hover {font-size:150%;}
a.three:link {color:#ff0000;}
a.three:visited {color:#0000ff;}
a.three:hover {background:#66ff66;}
a.four:link {color:#ff0000;}
a.four:visited {color:#0000ff;}
a.four:hover {font-family:monospace;}
a.five:link {color:#ff0000;text-decoration:none;}
a.five:visited {color:#0000ff;text-decoration:none;}
a.five:hover {text-decoration:underline;}
</style>
</head>
<body>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
</style>
</head>
<body>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
a:link, a:visited {
background-color: white;
color: black;
border: 2px solid green;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: green;
color: white;
}
</style>
</head>
<body>
Rezultati
CSS Lists
1) <!DOCTYPE html>
<html>
<head>
<style>
ul.a {list-style-type: circle;}
ul.b {list-style-type: disc;}
ul.c {list-style-type: square;}
<ul class="a">
<li>Circle type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
<ul class="b">
<li>Disc type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
<ul class="c">
<li>Square type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
<ol class="d">
<li>Armenian type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="e">
<li>Cjk-ideographic type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="f">
<li>Decimal type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="g">
<li>Decimal-leading-zero type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="h">
<li>Georgian type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="i">
<li>Hebrew type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="j">
<li>Hiragana type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="k">
<li>Hiragana-iroha type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="l">
<li>Katakana type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="m">
<li>Katakana-iroha type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="n">
<li>Lower-alpha type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="o">
<li>Lower-greek type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="p">
<li>Lower-latin type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="q">
<li>Lower-roman type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="r">
<li>Upper-alpha type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="s">
<li>Upper-latin type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="t">
<li>Upper-roman type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="u">
<li>None type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="v">
<li>inherit type</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
</body>
</html>
Rezultati
o Circle type
o Tea
o Coca Cola
Disc type
Tea
Coca Cola
Square type
Tea
Coca Cola
1. Armenian type
2. Tea
3. Coca Cola
1. Cjk-ideographic type
2. Tea
3. Coca Cola
1. Decimal type
2. Tea
3. Coca Cola
1. Decimal-leading-zero type
2. Tea
3. Coca Cola
1. Georgian type
2. Tea
3. Coca Cola
1. Hebrew type
2. Tea
3. Coca Cola
1. Hiragana type
2. Tea
3. Coca Cola
1. Hiragana-iroha type
2. Tea
3. Coca Cola
1. Katakana type
2. Tea
3. Coca Cola
1. Katakana-iroha type
2. Tea
3. Coca Cola
a. Lower-alpha type
b. Tea
c. Coca Cola
1. Lower-greek type
2. Tea
3. Coca Cola
1. Lower-latin type
2. Tea
3. Coca Cola
i. Lower-roman type
ii. Tea
A. Upper-alpha type
B. Tea
C. Coca Cola
1. Upper-latin type
2. Tea
3. Coca Cola
I. Upper-roman type
II. Tea
1. None type
2. Tea
3. Coca Cola
1. inherit type
2. Tea
3. Coca Cola
2) <!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-image: url('sqpurple.gif');
}
</style>
</head>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
ul.a {list-style-position:inside;}
ul.b {list-style-position:outside;}
</style>
</head>
<body>
<ul class="a">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
<ul class="b">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
ul {
</style>
</head>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
ol {
background: #ff9999;
padding: 20px;
}
ul {
background: #3399ff;
padding: 20px;
ol li {
background: #ffe5e5;
padding: 5px;
margin-left: 35px;
ul li {
background: #cce5ff;
margin: 5px;
</style>
</head>
<body>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
padding: 0;
ul li {
ul li:last-child {
border-bottom: none
</style>
</head>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
</body>
</html>
Rezultati
CSS Tables
1) <!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
}
table, td, th {
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
table, td, th {
table {
border-collapse: collapse;
width: 100%;
th {
height: 50px;
</style>
</head>
<body>
<p>Set the width of the table, and the height of the table header row:</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
table, td, th {
table {
border-collapse: collapse;
width: 100%;
th {
text-align: left;
</style>
</head>
<body>
<p>This property sets the horizontal alignment (like left, right, or center) of
the content in th or td:</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
table, td, th {
table {
border-collapse: collapse;
width: 100%;
}
td {
height: 50px;
vertical-align: bottom;
</style>
</head>
<body>
<p>This property sets the vertical alignment (like top, bottom, or middle) of
the content in th or td.</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
table, td, th {
text-align: left;
table {
border-collapse: collapse;
width: 100%;
th, td {
padding: 15px;
</style>
</head>
<body>
<p>This property adds space between the border and the content in a
table.</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
th, td {
padding: 8px;
text-align: left;
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
9) <!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
th, td {
padding: 8px;
text-align: left;
tr:hover{background-color:#f5f5f5}
</style>
</head>
<body>
<h2>Hoverable Table</h2>
<p>Move the mouse over the table rows to see the effect.</p>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
10) <!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
th, td {
text-align: left;
padding: 8px;
tr:nth-child(even){background-color: #f2f2f2}
</style>
</head>
<body>
<h2>Striped Table</h2>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
11) <!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
th, td {
text-align: left;
padding: 8px;
tr:nth-child(even){background-color: #f2f2f2}
th {
background-color: #4CAF50;
color: white;
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Rezultati
<html>
<head>
<style>
table, td, th {
caption {
caption-side: bottom;
}
</style>
</head>
<body>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr class="alt">
<td>Berglunds snabbkp</td>
<td>Christina Berglund</td>
<td>Sweden</td>
</tr>
<tr>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr class="alt">
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
</table>
</body>
</html>
Rezultati
13) <!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
</style>
</head>
<body>
<h2>Responsive Table</h2>
<p>A responsive table will display a horizontal scroll bar if the screen is too
small to display the full content. Resize the browser window to see the
effect:</p>
<p>To create a responsive table, add a container element (like div) with
<strong>overflow-x:auto</strong> around the table element:</p>
<div style="overflow-x:auto;">
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
<th>Points</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
<td>50</td>
<td>50</td>
<td>50</td>
<td>50</td>
<td>50</td>
<td>50</td>
<td>50</td>
<td>50</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
<td>94</td>
<td>94</td>
<td>94</td>
<td>94</td>
<td>94</td>
<td>94</td>
<td>94</td>
<td>94</td>
<td>94</td>
</tr>
<tr>
<td>Adam</td>
<td>Johnson</td>
<td>67</td>
<td>67</td>
<td>67</td>
<td>67</td>
<td>67</td>
<td>67</td>
<td>67</td>
<td>67</td>
<td>67</td>
<td>67</td>
</tr>
</table>
</div>
</body>
</html>
Rezultati
14) <!DOCTYPE html>
<html>
<head>
<style>
#customers {
border-collapse: collapse;
width: 100%;
padding: 8px;
#customers th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
</style>
</head>
<body>
<table id="customers">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Berglunds snabbkp</td>
<td>Christina Berglund</td>
<td>Sweden</td>
</tr>
<tr>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
<tr>
<td>Kniglich Essen</td>
<td>Philip Cramer</td>
<td>Germany</td>
</tr>
<tr>
<td>Yoshi Tannamuri</td>
<td>Canada</td>
</tr>
<tr>
<td>Giovanni Rovelli</td>
<td>Italy</td>
</tr>
<tr>
<td>North/South</td>
<td>Simon Crowther</td>
<td>UK</td>
</tr>
<tr>
<td>Paris spcialits</td>
<td>Marie Bertrand</td>
<td>France</td>
</tr>
</table>
</body>
</html>
Rezultati
CSS Display
1) <!DOCTYPE html>
<html>
<head>
<style>
h1.hidden {
visibility: hidden;
</style>
</head>
<body>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
h1.hidden {
display: none;
</style>
</head>
<body>
<p>Notice that the h1 element with display: none; does not take up any space.</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
.imgbox {
float: left;
text-align: center;
width: 120px;
margin: 4px;
padding: 6px;
button {
width: 100%;
</style>
</head>
<body>
<button onclick="removeElement()">Remove</button>
</div>
<button onclick="changeVisibility()">Hide</button>
</div>
</div>
<script>
function removeElement() {
document.getElementById("imgbox1").style.display = "none";
function changeVisibility() {
document.getElementById("imgbox2").style.visibility = "hidden";
function resetElement() {
document.getElementById("imgbox1").style.display = "block";
document.getElementById("imgbox2").style.visibility = "visible";
</script>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
span {
display: block;
</style>
</head>
<body>
<span>A display property with a value of "block" results in</span> <span>a line
break between the two elements.</span>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
#panel, .flip {
font-size: 16px;
padding: 10px;
text-align: center;
background-color: #4CAF50;
color: white;
margin: auto;
#panel {
display: none;
}
</style>
</head>
<body>
<div id="panel">
</div>
<script>
function myFunction() {
document.getElementById("panel").style.display = "block";
}
</script>
</body>
</html>
Rezultati
CSS Positioning
Position an element relative to the browser window
Position an element relative to its normal position
Position an element with an absolute value
Overlapping elements
Set the shape of an element
How to create a scroll bar when an element's content is too big to fit
How to set the browser to automatically handle overflow
Set the top edge of an image using a pixel value
Set the bottom edge of an image using a pixel value
Set the left edge of an image using a pixel value
Set the right edge of an image using a pixel value
Change the cursor
Position image text (top left corner)
Position image text (top right corner)
Position image text (bottom left corner)
Position image text (bottom right corner)
Position image text (centered)
1) <!DOCTYPE html>
<html>
<head>
<style>
div.fixed {
position: fixed;
bottom: 0;
right: 0;
width: 300px;
</style>
</head>
<body>
<h2>position: fixed;</h2>
<p>An element with position: fixed; is positioned relative to the viewport, which
means it always stays in the same place even if the page is scrolled:</p>
<div class="fixed">
</div>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
div.relative {
position: relative;
left: 30px;
</style>
</head>
<body>
<h2>position: relative;</h2>
<div class="relative">
</div>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
div.relative {
position: relative;
width: 400px;
height: 200px;
div.absolute {
position: absolute;
top: 80px;
right: 0;
width: 200px;
height: 100px;
</style>
</head>
<body>
<h2>position: absolute;</h2>
<p>An element with position: absolute; is positioned relative to the nearest positioned
ancestor (instead of positioned relative to the viewport, like fixed):</p>
</div>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>Because the image has a z-index of -1, it will be placed behind the text.</p>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute;
clip: rect(0px,60px,200px,0px);
</style>
</head>
<body>
<img src="w3css.gif" width="100" height="140">
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
div.scroll {
background-color: #00FFFF;
width: 100px;
height: 100px;
overflow: scroll;
div.hidden {
background-color: #00FF00;
width: 100px;
height: 100px;
overflow: hidden;
</style>
</head>
<body>
<div class="scroll">You can use the overflow property when you want to have better
control of the layout. The default value is visible.</div>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #00FFFF;
width: 150px;
height: 150px;
overflow: auto;
</style>
</head>
<body>
<p>The overflow property decides what to do if the content inside an element exceeds
the given width and height properties.</p>
<div>You can use the overflow property when you want to have better control of the
layout. Try to change the overflow property to: visible, hidden, scroll, or inherit and
see what happens. The default value is visible.</div>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute;
top: 0px;
</style>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
Rezultati
9) <!DOCTYPE html>
<html>
<head>
<style>
img.ex1 {
position: absolute;
bottom: 0px;
img.ex2 {
position: relative;
bottom: -100px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
Rezultati
10) <!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute;
left: 50px;
</style>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
Rezultati
11) <!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute;
right: 50px;
</style>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
Rezultati
<html>
<body>
<span style="cursor:auto">auto</span><br>
<span style="cursor:crosshair">crosshair</span><br>
<span style="cursor:default">default</span><br>
<span style="cursor:e-resize">e-resize</span><br>
<span style="cursor:help">help</span><br>
<span style="cursor:move">move</span><br>
<span style="cursor:n-resize">n-resize</span><br>
<span style="cursor:ne-resize">ne-resize</span><br>
<span style="cursor:nw-resize">nw-resize</span><br>
<span style="cursor:pointer">pointer</span><br>
<span style="cursor:progress">progress</span><br>
<span style="cursor:s-resize">s-resize</span><br>
<span style="cursor:se-resize">se-resize</span><br>
<span style="cursor:sw-resize">sw-resize</span><br>
<span style="cursor:text">text</span><br>
<span style="cursor:w-resize">w-resize</span><br>
<span style="cursor:wait">wait</span><br>
</body>
</html>
Rezultati
<html>
<head>
<style>
.container {
position: relative;
.topleft {
position: absolute;
top: 8px;
left: 16px;
font-size: 18px;
}
img {
width: 100%;
height: auto;
opacity: 0.3;
</style>
</head>
<body>
<h2>Image Text</h2>
<div class="container">
</div>
</body>
</html>
Rezultati
14) <!DOCTYPE html>
<html>
<head>
<style>
.container {
position: relative;
.topright {
position: absolute;
top: 8px;
right: 16px;
font-size: 18px;
img {
width: 100%;
height: auto;
opacity: 0.3;
</style>
</head>
<body>
<h2>Image Text</h2>
<div class="container">
</div>
</body>
</html>
Rezultati
<html>
<head>
<style>
.container {
position: relative;
.bottomleft {
position: absolute;
bottom: 8px;
left: 16px;
font-size: 18px;
img {
width: 100%;
height: auto;
opacity: 0.3;
</style>
</head>
<body>
<h2>Image Text</h2>
<div class="container">
</div>
</body>
</html>
Rezultati
<html>
<head>
<style>
.container {
position: relative;
.bottomright {
position: absolute;
bottom: 8px;
right: 16px;
font-size: 18px;
img {
width: 100%;
height: auto;
opacity: 0.3;
</style>
</head>
<body>
<h2>Image Text</h2>
<div class="container">
</div>
</body>
</html>
Rezultati
<html>
<head>
<style>
.container {
position: relative;
.center {
position: absolute;
left: 0;
top: 50%;
width: 100%;
text-align: center;
font-size: 18px;
img {
width: 100%;
height: auto;
opacity: 0.3;
</style>
</head>
<body>
<h2>Image Text</h2>
<div class="container">
</div>
</body>
</html>
Rezultati
CSS Overflow
Using overflow: visible - The overflow is not clipped. It renders outside the element's
box.
Using overflow: hidden - The overflow is clipped, and the rest of the content is hidden.
Using overflow: scroll - The overflow is clipped, but a scrollbar is added to see the rest
of the content.
Using overflow: auto - If overflow is clipped, a scrollbar should be added to see the rest
of the content.
Using overflow-x and overflow-y.
1) <!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #eee;
width: 200px;
height: 50px;
overflow: visible;
</style>
</head>
<body>
<h2>CSS Overflow</h2>
<p>By default, the overflow is visible, meaning that it is not clipped and it renders
outside the element's box:</p>
<div>You can use the overflow property when you want to have better control of the
layout. The overflow property specifies what happens if content overflows an element's
box.</div>
</body>
</html>
Rezultati
CSS Overflow
By default, the overflow is visible, meaning that it is not clipped and it renders outside
the element's box:
You can use the overflow property when you want to have better
control of the layout. The overflow property specifies what happens
if content overflows an element's box.
2) <!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #eee;
width: 200px;
height: 50px;
overflow: hidden;
</style>
</head>
<body>
<h2>CSS Overflow</h2>
<p>With the hidden value, the overflow is clipped, and the rest of the content is
hidden:</p>
<div>You can use the overflow property when you want to have better control of the
layout. The overflow property specifies what happens if content overflows an element's
box.</div>
</body>
</html>
Rezultati
CSS Overflow
With the hidden value, the overflow is clipped, and the rest of the content is hidden:
You can use the overflow property when you want to have better
control of the layout. The overflow property specifies what happens
if content overflows an element's box.
3) <!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #eee;
width: 200px;
height: 50px;
overflow: scroll;
</style>
</head>
<body>
<h2>CSS Overflow</h2>
<p>Setting the overflow value to scroll, the overflow is clipped and a scrollbar is
added to scroll inside the box. Note that this will add a scrollbar both horizontally and
vertically (even if you do not need it):</p>
<div>You can use the overflow property when you want to have better control of the
layout. The overflow property specifies what happens if content overflows an
element's box.</div>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #eee;
width: 200px;
height: 50px;
overflow: auto;
</style>
</head>
<body>
<h2>CSS Overflow</h2>
<p>The auto value is similar to scroll, only it add scrollbars when necessary:</p>
<div>You can use the overflow property when you want to have better control of the
layout. The overflow property specifies what happens if content overflows an
element's box.</div>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #eee;
width: 200px;
height: 50px;
overflow-x: hidden;
overflow-y: scroll;
</style>
</head>
<body>
<h2>CSS Overflow</h2>
</body>
</html>
Rezultati
CSS Floating
1) <!DOCTYPE html>
<html>
<head>
<style>
img {
float: right;
</style>
</head>
<body>
<p>In the paragraph below, we have added an image with style <b>float:right</b>.
The result is that the image will float to the right in the paragraph.</p>
</p>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
img {
float: right;
</style>
</head>
<body>
<p>In the paragraph below, the image will float to the right. A dotted black border is
added to the image.
We have also added margins to the image to push the text away from the image:
0 px margin on the top and right side, 15 px margin on the bottom, and 20 px margin
on the left side of the image.
</p>
</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
div {
float: right;
width: 120px;
padding: 15px;
text-align: center;
}
</style>
</head>
<body>
<div>
</div>
<p>
<p>
In the paragraph above, the div element is 120 pixels wide and it contains the image.
The div element will float to the right. Margins are added to the div to push the text
away from the div.
Borders and padding are added to the div to frame in the picture and the caption.
</p>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
span {
float: left;
width: 0.7em;
font-size: 400%;
line-height: 80%;
</style>
</head>
<body>
<p>
</p>
<p>
In the paragraph above, the first letter of the text is embedded in a span element.
The span element has a width that is 0.7 times the size of the current font.
The font-size of the span element is 400% (quite large) and the line-height is 80%.
</p>
</body>
</html>
Rezultati
This is some text. This is some text. This is some text. This is some text. This is
some text. This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text. This is some
text. This is some text. This is some text. This is some text. This is some text. This is
some text. This is some text. This is some text.
In the paragraph above, the first letter of the text is embedded in a span element. The
span element has a width that is 0.7 times the size of the current font. The font-size of
the span element is 400% (quite large) and the line-height is 80%. The font of the
letter in the span will be in "Algerian".
5) <!DOCTYPE html>
<html>
<head>
<style>
.floating-box {
float: left;
width: 150px;
height: 75px;
margin: 10px;
</style>
</head>
<body>
<h2>Floating boxes</h2>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
.div1 {
float: left;
width: 100px;
height: 50px;
margin: 10px;
.div2 {
.div3 {
float: left;
width: 100px;
height: 50px;
margin: 10px;
.div4 {
clear: left;
}
</style>
</head>
<body>
<h2>Without clear</h2>
<div class="div1">div1</div>
<div class="div2">div2 - Notice that the div2 element is after div1, in the HTML
code. However, since div1 is floated to the left, this happens: the text in div2 is floated
around div1, and div2 surrounds the whole thing.</div>
<h2>Using clear</h2>
<div class="div3">div3</div>
<div class="div4">div4 - Using clear moves div4 down below the floated div3. The
value "left" clears elements floated to the left. You can also clear "right" and
"both".</div>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
li a {
display: inline-block;
color: white;
text-align: center;
text-decoration: none;
li a:hover {
background-color: #111;
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
div.container {
width: 100%;
margin: 0px;
line-height: 150%;
div.header, div.footer {
padding: 0.5em;
color: white;
background-color: gray;
clear: left;
h1.header {
padding: 0;
margin: 0;
div.left {
float: left;
width: 160px;
margin: 0;
padding: 1em;
div.content {
margin-left: 190px;
padding: 1em;
overflow: hidden;
</style>
</head>
<body>
<div class="container">
<div class="content">
<p>At W3Schools you will find all the Web-building tutorials you need.</p>
</div>
</body>
</html>
Rezultati
1) <!DOCTYPE html>
<html>
<head>
<style>
.center {
margin: auto;
width: 60%;
padding: 10px;
</style>
</head>
<body>
<p>To horizontally center a block element (like div), use margin: auto;</p>
<div class="center">
</div>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
}
</style>
</head>
<body>
<h2>Center Text</h2>
<div class="center">
</div>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
img {
display: block;
margin: 0 auto;
</style>
</head>
<body>
<h2>Center an Image</h2>
<p>To center an image, use margin: auto; and make it into a block element:</p>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
.right {
position: absolute;
right: 0px;
width: 300px;
padding: 10px;
</style>
</head>
<body>
<h2>Right Align</h2>
<p>An example of how to right align elements with the position property:</p>
<div class="right">
<p>In my younger and more vulnerable years my father gave me some advice that
I've been turning over in my mind ever since.</p>
</div>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
padding: 0;
.container {
position: relative;
width: 100%;
}
.right {
position: absolute;
right: 0px;
width: 300px;
background-color: #b0e0e6;
</style>
</head>
<body>
<h2>Right Align</h2>
<div class="container">
<div class="right">
<p><b>Note: </b>When aligning using the position property, always include the !
DOCTYPE declaration! If missing, it can produce strange results in IE browsers.</p>
</div>
</div>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
.right {
float: right;
width: 300px;
padding: 10px;
</style>
</head>
<body>
<h2>Right Align</h2>
<p>An example of how to right align elements with the float property:</p>
<div class="right">
</div>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
padding: 0;
.right {
float: right;
width: 300px;
background-color: #b0e0e6;
</style>
</head>
<body>
<h2>Right Align</h2>
<div class="right">
</div>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
.center {
padding: 70px 0;
</style>
</head>
<body>
<h2>Center Vertically</h2>
<p>In this example, we use the padding property to center the div element
vertically:</p>
<div class="center">
</div>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
.center {
padding: 70px 0;
text-align: center;
</style>
</head>
<body>
<h2>Centering</h2>
<p>In this example, we use padding and text-align to center the div element
vertically and horizontally:</p>
<div class="center">
</div>
</body>
</html>
Rezultati
9) <!DOCTYPE html>
<html>
<head>
<style>
.center {
line-height: 200px;
height: 200px;
text-align: center;
.center p {
line-height: 1.5;
display: inline-block;
vertical-align: middle;
</style>
</head>
<body>
<h2>Centering</h2>
<p>In this example, we use the line-height property with a value that is
equal to the height property to center the div element:</p>
<div class="center">
</div>
</body>
</html>
Rezultati
10) <!DOCTYPE html>
<html>
<head>
<style>
.center {
height: 200px;
position: relative;
.center p {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
</style>
</head>
<body>
<h2>Centering</h2>
<div class="center">
</div>
</body>
</html>
Rezultati
CSS Combinators
Descendant selector
Child selector
Adjacent Sibling selector
General Sibling selector
1) <!DOCTYPE html>
<html>
<head>
<style>
div p {
background-color: yellow;
</style>
</head>
<body>
<div>
</div>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
div > p {
background-color: yellow;
</style>
</head>
<body>
<div>
</div>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
div + p {
background-color: yellow;
</style>
</head>
<body>
<div>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
div ~ p {
background-color: yellow;
}
</style>
</head>
<body>
<p>Paragraph 1.</p>
<div>
<code>Some code.</code>
<p>Paragraph 2.</p>
</div>
<p>Paragraph 3.</p>
<code>Some code.</code>
<p>Paragraph 4.</p>
</body>
</html>
Rezultati
CSS Generated Content
Insert the URL in parenthesis after each link with the content property
Numbering sections and sub-sections with "Section 1", "1.1", "1.2", etc.
Specify the quotation marks with the quotes property
1) <!DOCTYPE html>
<html>
<head>
<style>
a:after {
</style>
</head>
<body>
<p><a href="http://www.w3schools.com">W3Schools</a> contains free
tutorials and references.</p>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
body {
counter-reset: section;
}
h1 {
counter-reset: subsection;
h1:before {
counter-increment: section;
h2:before {
counter-increment: subsection;
</style>
</head>
<body>
<h1>HTML tutorials</h1>
<h2>HTML Tutorial</h2>
<h2>XHTML Tutorial</h2>
<h2>CSS Tutorial</h2>
<h1>Scripting tutorials</h1>
<h2>JavaScript</h2>
<h2>JQuery</h2>
<h1>XML tutorials</h1>
<h2>XML</h2>
<h2>XSL</h2>
</body>
</html>
Rezultati
3) <html lang="en">
<head>
<style>
q:lang(en) {
</style>
</head>
<body>
</html>
Rezultati
CSS Pseudo-classes
1) <!DOCTYPE html>
<html>
<head>
<style>
/* unvisited link */
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
a:hover {
color: hotpink;
/* selected link */
a:active {
color: blue;
</style>
</head>
<body>
<p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS
definition in order to be effective.</p>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
a.one:link {color:#ff0000;}
a.one:visited {color:#0000ff;}
a.one:hover {color:#ffcc00;}
a.two:link {color:#ff0000;}
a.two:visited {color:#0000ff;}
a.two:hover {font-size:150%;}
a.three:link {color:#ff0000;}
a.three:visited {color:#0000ff;}
a.three:hover {background:#66ff66;}
a.four:link {color:#ff0000;}
a.four:visited {color:#0000ff;}
a.four:hover {font-family:monospace;}
a.five:link {color:#ff0000;text-decoration:none;}
a.five:visited {color:#0000ff;text-decoration:none;}
a.five:hover {text-decoration:underline;}
</style>
</head>
<body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
input:focus {
background-color: yellow;
</style>
</head>
<body>
<form action="form_action.asp" method="get">
</form>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
p:first-child {
color: blue;
</style>
</head>
<body>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
p i:first-child {
color: blue;
</style>
</head>
<body>
</body>
</html>
Rezultati
Note: For :first-child to work in IE8 and earlier, a DOCTYPE must be declared.
6) <!DOCTYPE html>
<html>
<head>
<style>
p:first-child i {
color: blue;
</style>
</head>
<body>
</body>
</html>
Rezultati
Note: For :first-child to work in IE8 and earlier, a DOCTYPE must be declared.
7) <!DOCTYPE html>
<html>
<head>
<style>
q:lang(no) {
</style>
</head>
<body>
</body>
</html>
Rezultati
CSS Pseudo-elements
1) <!DOCTYPE html>
<html>
<head>
<style>
p::first-letter {
color: #ff0000;
font-size: xx-large;
</style>
</head>
<body>
<p>You can use the ::first-letter pseudo-element to add a special effect to the first character of a text!</p>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
p::first-line {
color: #ff0000;
font-variant: small-caps;
</style>
</head>
<body>
<p>You can use the ::first-line pseudo-element to add a special effect to the first line
of a text. Some more text. And even more, and more, and more, and more, and more,
and more, and more, and more, and more, and more, and more, and more.</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
p::first-letter {
color: #ff0000;
font-size: xx-large;
p::first-line {
color: #0000ff;
font-variant: small-caps;
</style>
</head>
<body>
<p>You can combine the ::first-letter and ::first-line pseudo-elements to add a special
effect to the first letter and the first line of a text!</p>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
h1::before {
content: url(smiley.gif);
</style>
</head>
<body>
<h1>This is a heading</h1>
<h1>This is a heading</h1>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
h1::after {
content: url(smiley.gif);
</style>
</head>
<body>
<h1>This is a heading</h1>
<h1>This is a heading</h1>
</body>
</html>
Rezultati
CSS Opacity
1) <!DOCTYPE html>
<html>
<head>
<style>
img {
opacity: 0.5;
</style>
</head>
<body>
<h1>Image Transparency</h1>
<p>The opacity property specifies the transparency of an element. The lower the value, the more transparent:</p>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
img {
opacity: 0.5;
img:hover {
opacity: 1.0;
</style>
</head>
<body>
<h1>Image Transparency</h1>
<p>The opacity property is often used together with the :hover selector to change the
opacity on mouse-over:</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
img:hover {
opacity: 0.5;
</style>
</head>
<body>
<h1>Image Transparency</h1>
<p>The opacity property is often used together with the :hover selector to change the
opacity on mouse-over:</p>
<p><b>Note:</b> In IE, a !DOCTYPE must be added for the :hover selector to work
on other elements than the a element.</p>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #4CAF50;
padding: 10px;
div.first {
opacity: 0.1;
div.second {
opacity: 0.3;
div.third {
opacity: 0.6;
</style>
</head>
<body>
<h1>Transparent Box</h1>
<div><p>opacity 1 (default)</p></div>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
div {
padding: 10px;
div.first {
div.second {
div.third {
</style>
</head>
<body>
<h1>Transparent Box</h1>
<p>With opacity:</p>
<div><p>opacity 1</p></div>
<div><p>default</p></div>
<p>Notice how the text gets transparent as well as the background color when using
the opacity property.</p>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
div.background {
div.transbox {
margin: 30px;
background-color: #ffffff;
opacity: 0.6;
div.transbox p {
margin: 5%;
font-weight: bold;
color: #000000;
}
</style>
</head>
<body>
<div class="background">
<div class="transbox">
</div>
</div>
</body>
</html>
Rezultati
CSS Navigation Bars
1) <!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 200px;
background-color: #f1f1f1;
li a {
display: block;
color: #000;
text-decoration: none;
li a.active {
background-color: #4CAF50;
color: white;
li a:hover:not(.active) {
background-color: #555;
color: white;
</style>
</head>
<body>
<p>In this example, we create an "active" class with a green background color and a
white text. The class is added to the "Home" link.</p>
<ul>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
li a {
display: block;
color: white;
text-align: center;
text-decoration: none;
a:hover:not(.active) {
background-color: #111;
.active {
background-color:#4CAF50;
}
</style>
</head>
<body>
<ul>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>
Rezultati
CSS Dropdowns
Dropdown text
Dropdown menu
Right-aligned dropdown menu
Dropdown image
Dropdown navigation bar
1) <!DOCTYPE html>
<html>
<head>
<style>
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
.dropdown:hover .dropdown-content {
display: block;
</style>
</head>
<body>
<h2>Hoverable Dropdown</h2>
<p>Move the mouse over the text below to open the dropdown content.</p>
<div class="dropdown">
<div class="dropdown-content">
<p>Hello World!</p>
</div>
</div>
</body>
</html>
Rezultati
Hoverable Dropdown
Move the mouse over the text below to open the dropdown content.
Mouse over me
2) <!DOCTYPE html>
<html>
<head>
<style>
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
.dropdown {
position: relative;
display: inline-block;
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
.dropdown:hover .dropdown-content {
display: block;
.dropdown:hover .dropbtn {
background-color: #3e8e41;
</style>
</head>
<body>
<h2>Dropdown Menu</h2>
<p>Move the mouse over the button to open the dropdown menu.</p>
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
</div>
</div>
<p><strong>Note:</strong> We use href="#" for test links. In a real web site this
would be URLs.</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
.dropdown-content {
display: none;
position: absolute;
right: 0;
background-color: #f9f9f9;
min-width: 160px;
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
</style>
</head>
<body>
<p>Determine whether the dropdown content should go from left to right or right to
left with the left and right properties.</p>
<button class="dropbtn">Left</button>
</div>
</div>
<button class="dropbtn">Right</button>
<div class="dropdown-content">
</div>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
.dropdown:hover .dropdown-content {
display: block;
.desc {
padding: 15px;
text-align: center;
</style>
</head>
<body>
<h2>Dropdown Image</h2>
<p>Move the mouse over the image below to open the dropdown content.</p>
<div class="dropdown">
</div>
</div>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
li {
float: left;
li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
text-decoration: none;
background-color: red;
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
text-align: left;
.dropdown:hover .dropdown-content {
display: block;
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li class="dropdown">
<div class="dropdown-content">
</div>
</li>
</ul>
</body>
</html>
Rezultati
CSS Tooltips
Right tooltip
Left tooltip
Top tooltip
Bottom tooltip
Tooltip with arrow
Animated tooltip
1) <!DOCTYPE html>
<html>
<style>
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
left: 105%;
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>
<body style="text-align:center;">
<h2>Right Tooltip</h2>
</div>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<style>
.tooltip {
position: relative;
display: inline-block;
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
right: 105%;
.tooltip:hover .tooltiptext {
visibility: visible;
</style>
<body style="text-align:center;">
<h2>Left Tooltip</h2>
</div>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<style>
.tooltip {
position: relative;
display: inline-block;
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 100%;
left: 50%;
margin-left: -60px;
.tooltip:hover .tooltiptext {
visibility: visible;
</style>
<body style="text-align:center;">
<h2>Top Tooltip</h2>
</div>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<style>
.tooltip {
position: relative;
display: inline-block;
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 100%;
left: 50%;
margin-left: -60px;
.tooltip:hover .tooltiptext {
visibility: visible;
</style>
<body style="text-align:center;">
<h2>Bottom Tooltip</h2>
</div>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<style>
.tooltip {
position: relative;
display: inline-block;
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 150%;
left: 50%;
margin-left: -60px;
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
.tooltip:hover .tooltiptext {
visibility: visible;
</style>
<body style="text-align:center;">
</div>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<style>
.tooltip {
position: relative;
display: inline-block;
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 100%;
left: 50%;
margin-left: -60px;
opacity: 0;
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
<body style="text-align:center;">
<p>When you move the mouse over the text below, the tooltip text will fade in and
take 1 second to go from completely invisible to visible.</p>
</div>
</body>
</html>
Rezultati
CSS Image Gallery
Image gallery
Responsive Image gallery
1) <!DOCTYPE html>
<html>
<head>
<style>
div.img {
margin: 5px;
float: left;
width: 180px;
div.img:hover {
border: 1px solid #777;
div.img img {
width: 100%;
height: auto;
div.desc {
padding: 15px;
text-align: center;
</style>
</head>
<body>
<div class="img">
</a>
</div>
<div class="img">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
</a>
</div>
<div class="img">
</a>
</div>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
div.img {
div.img:hover {
div.img img {
width: 100%;
height: auto;
div.desc {
padding: 15px;
text-align: center;
*{
box-sizing: border-box;
.responsive {
padding: 0 6px;
float: left;
width: 24.99999%;
.responsive {
width: 49.99999%;
margin: 6px 0;
.responsive {
width: 100%;
.clearfix:after {
content: "";
display: table;
clear: both;
</style>
</head>
<body>
<div class="responsive">
<div class="img">
</a>
</div>
</div>
<div class="responsive">
<div class="img">
</a>
</div>
</div>
<div class="responsive">
<div class="img">
</a>
</div>
</div>
<div class="responsive">
<div class="img">
</a>
</div>
</div>
<div class="clearfix"></div>
<div style="padding:6px;">
<p>This example use media queries to re-arrange the images on different screen sizes: for screens larger than 700px wide, it will
show four images side by side, for screens smaller than 700px, it will show two images side by side. For screens smaller than
500px, the images will stack vertically (100%).</p>
<p>You will learn more about media queries and responsive web design later in our CSS Tutorial.</p>
</div>
</body>
</html>
Rezultati
CSS Image Sprites
An image sprite
An image sprite - a navigation list
An image sprite with hover effect
1) <!DOCTYPE html>
<html>
<head>
<style>
#home {
width: 46px;
height: 44px;
background: url(img_navsprites.gif) 0 0;
#next {
width: 43px;
height: 44px;
</style>
</head>
<body>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
#navlist {
position: relative;
#navlist li {
margin: 0;
padding: 0;
list-style: none;
position: absolute;
top: 0;
height: 44px;
display: block;
#home {
left: 0px;
width: 46px;
background: url('img_navsprites.gif') 0 0;
}
#prev {
left: 63px;
width: 43px;
#next {
left: 129px;
width: 43px;
</style>
</head>
<body>
<ul id="navlist">
</ul>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
#navlist {
position: relative;
#navlist li {
margin: 0;
padding: 0;
list-style: none;
position: absolute;
top: 0;
}
height: 44px;
display: block;
#home {
left: 0px;
width: 46px;
background: url('img_navsprites_hover.gif') 0 0;
#prev {
left: 63px;
width: 43px;
#next {
left: 129px;
width: 43px;
#home a:hover {
#prev a:hover {
#next a:hover {
</style>
</head>
<body>
<ul id="navlist">
</ul>
</body>
</html>
Rezultati
CSS Attribute Selectors
1) <!DOCTYPE html>
<html>
<head>
<style>
a[target] {
background-color: yellow;
</style>
</head>
<body>
<p>The links with a target attribute gets a yellow background:</p>
<a href="http://www.w3schools.com">w3schools.com</a>
<p><b>Note:</b> For [<i>attribute</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p>
</body>
</html>
Rezultati
2) <!DOCTYPE html>
<html>
<head>
<style>
a[target=_blank] {
background-color: yellow;
</style>
</head>
<body>
<a href="http://www.w3schools.com">w3schools.com</a>
<p><b>Note:</b> For [<i>attribute</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
[title~=flower] {
</style>
</head>
<body>
<p>All images with the title attribute containing the word "flower" get a yellow border.</p>
<p><b>Note:</b> For [<i>attribute</i>~=<i>value</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p>
</body>
</html>
Rezultati
4) <!DOCTYPE html>
<html>
<head>
<style>
[class|=top] {
background: yellow;
</style>
</head>
<body>
<h1 class="top-header">Welcome</h1>
</body>
</html>
Rezultati
5) <!DOCTYPE html>
<html>
<head>
<style>
[class^="top"] {
background: yellow;
</style>
</head>
<body>
<h1 class="top-header">Welcome</h1>
<p><b>Note:</b> For [<i>attribute</i>^=<i>value</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p>
</body>
</html>
Rezultati
6) <!DOCTYPE html>
<html>
<head>
<style>
[class$="test"] {
background: yellow;
</style>
</head>
<body>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
[class*="te"] {
background: yellow;
</style>
</head>
<body>
</body>
</html>
Rezultati
CSS Forms
1)
2)
3)
4)
5)
6) <!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
width: 100%;
margin: 8px 0;
box-sizing: border-box;
outline: none;
}
input[type=text]:focus {
background-color: lightblue;
</style>
</head>
<body>
<p>In this example, we use the :focus selector to add a background color to the text field when it gets focused (clicked on):</p>
<form>
</form>
</body>
</html>
Rezultati
7) <!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
width: 100%;
margin: 8px 0;
box-sizing: border-box;
-webkit-transition: 0.5s;
transition: 0.5s;
outline: none;
input[type=text]:focus {
</style>
</head>
<body>
<p>In this example, we use the :focus selector to add a black border color to the text
field when it gets focused (clicked on):</p>
<p>Note that we have added the CSS3 transition property to animate the border color
(takes 0.5 seconds to change the color on focus).</p>
<form>
</body>
</html>
Rezultati
8) <!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
width: 100%;
box-sizing: border-box;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-repeat: no-repeat;
</style>
</head>
<body>
<form>
</form>
</body>
</html>
Rezultati
9) <!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
input[type=text]:focus {
width: 100%;
</style>
</head>
<body>
<form>
</form>
</body>
</html>
Rezultati
10) <!DOCTYPE html>
<html>
<head>
<style>
textarea {
width: 100%;
height: 150px;
box-sizing: border-box;
border-radius: 4px;
background-color: #f8f8f8;
font-size: 16px;
resize: none;
}
</style>
</head>
<body>
<form>
<textarea>Some text...</textarea>
</form>
</body>
</html>
Rezultati
11) <!DOCTYPE html>
<html>
<head>
<style>
select {
width: 100%;
border: none;
border-radius: 4px;
background-color: #f1f1f1;
</style>
</head>
<body>
<p>A styled select menu.</p>
<form>
<option value="au">Australia</option>
<option value="ca">Canada</option>
<option value="usa">USA</option>
</select>
</form>
</body>
</html>
Rezultati
12) <!DOCTYPE html>
<html>
<head>
<style>
background-color: #4CAF50;
border: none;
color: white;
text-decoration: none;
cursor: pointer;
</style>
</head>
<body>
</body>
</html>
Rezultati
CSS Counters
Create a counter
Nested counters 1
Nested counters 2
1)
2) <!DOCTYPE html>
<html>
<head>
<style>
body {
counter-reset: section;
h1 {
counter-reset: subsection;
}
h1::before {
counter-increment: section;
h2::before {
counter-increment: subsection;
</style>
</head>
<body>
<h1>HTML tutorials:</h1>
<h2>HTML Tutorial</h2>
<h2>CSS Tutorial</h2>
<h1>Scripting tutorials:</h1>
<h2>JavaScript</h2>
<h2>VBScript</h2>
<h1>XML tutorials:</h1>
<h2>XML</h2>
<h2>XSL</h2>
<p><b>Note:</b> IE8 supports these properties only if a !DOCTYPE is
specified.</p>
</body>
</html>
Rezultati
3) <!DOCTYPE html>
<html>
<head>
<style>
ol {
counter-reset: section;
list-style-type: none;
}
li::before {
counter-increment: section;
</style>
</head>
<body>
<ol>
<li>item</li>
<li>item
<ol>
<li>item</li>
<li>item</li>
<li>item
<ol>
<li>item</li>
<li>item</li>
<li>item</li>
</ol>
</li>
<li>item</li>
</ol>
</li>
<li>item</li>
<li>item</li>
</ol>
<ol>
<li>item</li>
<li>item</li>
</ol>
</body>
</html>
Rezultati