
<LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen> <LINK REL=StyleSheet HREF="color-8b.css" TYPE="text/css" TITLE="8-bit Color Style" MEDIA="screen, print"> <LINK REL="Alternate StyleSheet" HREF="color-24b.css" TYPE="text/css" TITLE="24-bit Color Style" MEDIA="screen, print"> <LINK REL=StyleSheet HREF="aural.css" TYPE="text/css" MEDIA=aural>
<LINK REL=StyleSheet HREF="basics.css" TITLE="Contemporary"> <LINK REL=StyleSheet HREF="tables.css" TITLE="Contemporary"> <LINK REL=StyleSheet HREF="forms.css" TITLE="Contemporary">
Neste exemplo, três folhas de estilo são combinadas em um estilo "Contemporary" que é
aplicado como uma folha de estilo preferencial. Para combinar várias folhas de estilo em um único
estilo, deve-se usar o mesmo TITLE com cada folha de estilo.
Uma folha de estilo externa é ideal quando o estilo é aplicado a várias páginas. Com uma folha
de estilo externa, um autor pode mudar a aparência de um site inteiro simplesmente mudando um arquivo.
Da mesma forma, a maioria dos navegadores armazenará em cache uma folha de estilo externa, evitando
atrasos na apresentação da página depois que a folha de estilo for armazenada em cache.<!DOCTYPE html>
<html>
<head>
<style>
p {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p>Every paragraph will be affected by the style.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
#id1 {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p id="id1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">Red and center-aligned heading</h1>
<p class="center">Red and center-aligned paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
p.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">This heading will not be affected</h1>
<p class="center">This paragraph will be red and center-aligned.</p>
</body>
</html>
<!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>
<!DOCTYPE html>
<html>
<head>
<style>
* {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1>Hello world!</h1>
<p>Every element on the page will be affected by the style.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
<!DOCTYPE html >
<html >
<head >
<style >
div p {
background-color: yellow;
}
</style >
</head >
<body >
<h2 >Descendant Selector</h2 >
<p >The descendant selector matches all elements that are descendants of a specified element.</p >
<div >
<p >Paragraph 1 in the div.</p >
<p >Paragraph 2 in the div.</p >
<section >
<p >Paragraph 3 in the div.</p >
</section >
</div >
<p >Paragraph 4. Not in a div.</p >
<p >Paragraph 5. Not in a div.</p >
</body >
</html >
<!DOCTYPE html>
<html>
<head>
<style>
div>p {
background-color: yellow;
}
</style>
</head>
<body>
<h2>Child Selector</h2>
<p>The child selector (>) selects all elements that are the children of a specified element.</p>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
<section>
<p>Paragraph 3 in the div.</p>
</section> <!-- not Child but Descendant -->
<p>Paragraph 4 in the div.</p>
</div>
<p>Paragraph 5. Not in a div.</p>
<p>Paragraph 6. Not in a div.</p>
</body>
</html>
<!DOCTYPE html >
<html >
<head >
<style >
div + p {
background-color: yellow;
}
</style >
</head >
<body >
<h2 >Adjacent Sibling Selector</h2 >
<p >The adjacent sibling selector (+) selects all elements that are the adjacent siblings of a specified element.</p >
<div >
<p >Paragraph 1 in the div.</p >
<p >Paragraph 2 in the div.</p >
</div >
<p >Paragraph 3. Not in a div.</p >
<p >Paragraph 4. Not in a div.</p >
</body >
</html >
<!DOCTYPE html>
<html>
<head>
<style>
div~p {
background-color: yellow;
}
</style>
</head>
<body>
<h2>General Sibling Selector</h2>
<p>The general sibling selector (~) selects all elements that are siblings of a specified element.</p>
<p>Paragraph 1.</p>
<div>
<p>Paragraph 2.</p>
</div>
<p>Paragraph 3.</p>
<code>Some code.</code>
<p>Paragraph 4.</p>
</body>
</html>
selector:pseudo-class {
property: value;
}
<!DOCTYPE html>
<html>
<head>
<style>
/* unvisited link */
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: hotpink;
}
/* selected link */
a:active {
color: blue;
}
</style>
</head>
<body>
<h2>CSS Links</h2>
<p><b><a href="default.asp" target="_blank">This is a link</a></b></p>
<p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.</p>
<p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be effective.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
a.highlight:hover {
color: #ff0000;
}
</style>
</head>
<body>
<h2>Pseudo-classes and CSS Classes</h2>
<p>When you hover over the first link below, it will change color:</p>
<p><a class="highlight" href="css_syntax.asp">CSS Syntax</a></p>
<p><a href="default.asp">CSS Tutorial</a></p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: green;
color: white;
padding: 25px;
text-align: center;
}
div:hover {
background-color: blue;
}
</style>
</head>
<body>
<p>Mouse over the div element below to change its background color:</p>
<div>Mouse Over Me</div>
</body>
</html>
<!DOCTYPE html >
<!DOCTYPE html>
<html>
<head>
<style>
p {
display: none;
background-color: yellow;
padding: 20px;
}
div:hover p {
display: block;
}
</style>
</head>
<body>
<div>Passe o mouse sobre mim para mostrar o elemento p
<p>Exemplo do evento div:hover </p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
input:focus {
background-color: yellow;
}
</style>
</head>
<body>
<p>Click inside the text fields to see a yellow background:</p>
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
</body>
</html>
.