Escolar Documentos
Profissional Documentos
Cultura Documentos
Iniciante e Intermediário
FATEC-SP
2007
Folhas de Estilo
FOLHAS DE ESTILO
"CRIANDO PÁGINAS COM ESTILO"
Folhas de Estilo em Cascata (Cascading Style Sheets ou CSS) são regras utilizadas para a
formatação de páginas HTML. Através delas o código HTML é otimizado, podendo complementar
as definições obtidas através de tags HTML, como também alterar e criar efeitos especiais em
títulos, textos e elementos como imagens, formulários, barras de rolagem etc. Portanto, têm como
pré-requisito o conhecimento da linguagem HTML..
As tags HTML sem as marcas “<”(sinal de menor) e “>” (sinal de maior) são utilizadas como
elementos (seletores) em Folhas de Estilo.
O resultado de Folhas de Estilo pode variar de acordo com o navegador utilizado, é recomendável
testar em alguns navegadores (browser) como o Internet Explorer, Netscape, Ópera, Firefox...
2. Estilo Inline
O estilo é Inline quando definimos as regras de Folhas de Estilo dentro da tag HTML, no corpo da
página. Esta regra afeta somente a tag utilizada:
<body>
<tag style="propriedade1:valor1; propriedade2:valor2a, valor2b;...">
</body>
Exemplo 2.1:
<body>
<h3 style="color:red; text-decoration:underline;" > Título </h3>
</body>
3. Estilo Incorporado
<head>
<style type="text/css">
seletor {propriedade1:valor1;
propriedade2:valor2,valor3;
}
</style>
</head>
Exemplo 3.1:
<head>
<style type="text/css">
h1 { color:red;
font-style:"italic";
}
</style>
</head>
<body>
<h1> Título utilizando o estilo definido no cabeçalho </h1>
Texto normal entre as tags de título...
<h1> Outro título utilizando o estilo definido no cabeçalho </h1>
</body>
4. Estilo Externo
O Estilo é Externo quando definimos as regras de Folhas de Estilo em um arquivo à parte (bloco
de notas), salvo com extensão .css. As regras de estilos afetarão as página HTML que fizerem
chamada a este arquivo.
No arquivo externo só definimos as regras, ele não possui indicações de início e término do
código. É muito útil para alterar a aparência de várias páginas ao mesmo tempo.
A chamada deste arquivo é feita no cabeçalho de cada página HTML:
<head>
<link rel="..." href="..." type="...">
</head>
Exemplo 4.1:
<head>
<link rel="stylesheet" href="estilo1.css" type="text/css">
</head>
Profª. Elisabete da Silva Santos 5
FATEC-SP
Folhas de Estilo
<body>
<b> Negrito utilizando o estilo definido no arquivo externo </b1>
<p> Parágrafo utilizando o estilo definido no arquivo externo </p>
</body>
/* Comentário */
Exemplo 5.1:
/* Linha 1 de comentário
Linha 2 de comentário... */
Podemos comentar Folhas de Estilo com as tags de comentário de HTML, para os navegadores
que não suportam Folhas de Estilo e tão pouco a tag <nostyle>.
Exemplo 5.2:
<style type="text/css">
<!--
P {color:blue;}
-->
</style>
6. Propriedades de Fonte
7. Propriedades de Texto
Exemplo 18.1.:
<head>
<style type="text/css">
h1, p, div {font-style:italic;}
</style>
</head>
<body>
<h1> Fonte em itálico </h1>
</p> Fonte em itálico </p>
<div> Fonte em itálico </div>
</body>
Neste exemplo, <H1>, <P> e <DIV> sairão em itálico.
Profª. Elisabete da Silva Santos 10
FATEC-SP
Folhas de Estilo
O seletor contextual permite um controle mais detalhado sobre a aparência dos elementos HTML
em sua página. É declarado de acordo com um contexto, sem vírgulas entre os elementos.
Um elemento só é formatado quando estiver contido em um outro elemento.
Exemplo 19.1:
<head>
<style type="text/css">
p b {text-decoration:underline;}
</style>
</head>
<body>
<b>Negrito fora de parágrafo</b>
<p> Parágrafo sem negrito</p>
<p> Parágrafo...<b> Negrito dentro do parágrafo</b>...parágrafo.</p>
</body>
Neste exemplo, serão formatados todos os negritos que estiverem dentro de parágrafos.
<style type="text/css">
Elemento.NomedaClasse {propriedade:valor; ...}
</style>
Exemplo 20.1:
<head>
<style type="text/css">
h3.classe1 {color:green; }
h3.classe2 {font-style:italic;}
</style>
</head>
<body>
<h3> sem estilo </h3>
<h3 class="classe1"> Estilo classe1 </h3>
<h3 class="classe2"> Estilo classe2 </h3>
</body>
Exemplo 20.2:
<head>
<style type="text/css">
.classe3 {cursor:help;}
</style>
</head>
Profª. Elisabete da Silva Santos 11
FATEC-SP
Folhas de Estilo
<body>
<a href="pag1.html" class="classe3"> link1 </a><br>
</body>
Neste exemplo, o formato do cursor mudará para uma interrogação (?) ao passar sobre o link.
Podemos usar a classe3 em qualquer tag HTML, pois ela não está vinculada a um elemento específico.
21. Seletor de ID
A HTML introduziu o atributo ID, um identificador utilizado para garantir valores únicos sobre o
documento. O ID funciona semelhante às classes e é representado pelo símbolo # (em inglês
conhecido como number sign, mas no Brasil como: sustenido, “jogo da velha”, cardinal, hash,
cerquinha, tralha, grade etc.)
A “chamada” da regra é feita através do atributo ID da tag HTML.
<style type="text/css">
Elemento#NomedoID {propriedade:valor; ...}
</style>
Exemplo 21.1:
<head>
<style type="text/css">
p#id1{letter-spacing:0.5cm;}
#id2 {border:red groove 0.5cm;}
</style>
</head>
<body id="id2">
<p> Parágrafo sem id </p>
<p id="id1"> Parágrafo com id1 </p>
<img src="imagem1.jpg" id="id2">
</body>
Podemos utilizar classes e identificadores na mesma tag e até com os mesmos nomes.
Exemplo 22.1:
<head>
<style type="text/css">
.estilo1 {color:red;}
h2#estilo1{letter-spacing:0.4cm;}
</style>
</head>
<body>
<h2> h2 sem id </h2>
<h2 id="estilo1" class="estilo1"> h2 com id e classe</h2>
</body>
O seletor universal é um dos mais poderosos em CSS e atua como um coringa, estilizando todos
os elementos de uma página. Ele é representado por um asterisco ‘*’.
No exemplo a seguir, podemos alterar o preenchimento e a margem de cada elemento da página,
apenas com uma única regra.
Exemplo 23.1:
<head>
<style type="text/css">
* {padding: 20;
margin:20;
}
</style>
</head>
<body>
Corpo da página com margem e preenchimento
<h2>Título com margem e preenchimento </h2>
<p> Parágrafo com margem e preenchimento</p>
<b> Negrito com margem e preenchimento </b>
</body>
Exemplo 24.1:
<head>
<style type="text/css">
.cursor1 {cursor: crosshair;
}
.cursor2 {cursor: help;
}
.cursor3 {cursor: wait;
}
</style>
</head>
<body>
<h2 class="cursor1"> Título com cursor Crosshair </h2>
<p class="cursor2"> Parágrafo com cursor Help</p>
<a href="#" class="cursor3"> Link com cursor Wait </b>
</body>
25. Camadas
Uma camada é uma seção de uma página da Web que pode ser tratada como uma entidade
separada. Ela se utiliza das propriedades de Folhas de Estilo e utilizada com linguagens de script,
pode ser atualizada, reposicionada na tela e tornada oculta ou aparente dinamicamente.
O browser Netscape utiliza a tag <LAYER> para definir camadas, mas esta tag não é suportada pelo
I.E., por isso, é comum verificarmos a criação de camadas através da tag <DIV> ou <SPAN> que são
aceitas pelos dois navegadores e com a qual iremos trabalhar.
Exemplo 25.1:
<body>
<div id="camada1" style="position:absolute; left:100;
top:100;background-color:blue">
Este é o texto da camada
</div>
</body>
Exemplo 25.2:
<head>
<style type="text/css">
.quadro {position:absolute;
top:50px;
left: 300px;
width:150px;
height:150px;
background:url(imagem1.jpg);
color:green;
font-size:16pt;
}
</style>
</head>
<body>
<span class=quadro>
Texto da camada
</span>
</body>
26. Layouts
Layouts basicamente referem-se a tamanho e posicionamento de elementos em uma página.
Para centralizar um div container (caixa grande que contém outras caixas) horizontalmente na
janela:
Exemplo 26.1.
<style type="text/css">
#container { width:720px; /* 720px para se ajustar
a resolução 800x600 */
margin:0 auto;
text-align:left;
background-color:#ffffff;
padding:10px;
}
body {text-align:center;
background-color:#ccccff;
font-size:1em;
min-width: 760px;
}
</style>
</head>
<body>
<div id="container">
<h2> Título 1 </h2>
Texto texto texto texto texto texto texto texto
<h2> Título 2 </h2>
Texto texto texto texto texto texto texto texto
</div>
</body>
• Três dos mais importantes conceitos de CSS são flutuação, posicionamento e modelo de
caixa. Esses conceitos controlam a maneira como os elementos serão organizados e exibidos
em uma página, formando a base do layout CSS.
• As caixas substituem com excelência as tabelas que alguns programadores ou softwares
utilizam para organizar os dados.
26.2. Caixas
O modelo de caixa é uma das pedras angulares da CSS e determina a maneira como os
elementos serão exibidos e como eles interagem entre si. Cada elemento na página é
considerado uma caixa retangular composta de padding, border e margin.
Caixas flutuantes podem ser mudadas para a esquerda ou para a direita, até que sua borda
externa toque a borda da caixa que a contém ou uma outra caixa flutuante. Caixas flutuantes não
estão no fluxo normal do documento. Se não houver espaço horizontal suficiente, as caixas
flutuantes que não couberem serão deslocadas para baixo.
Exemplo 26.2.1.1:
<style type="text/css">
.conteiner {border: 1px dotted red;
width: 760px;
overflow: hidden;
margin-bottom: 40px;
background: #FFFCC4;
}
.caixa {background: beige;
border: 1px dotted gray;
width: 200px;
height: 100px;
margin: 20px;
padding:10px;
}
.esq {float:left;
margin-left:10px; margin-right:45px;
}
.dir {float:right;
}
</style>
</head>
<body>
<div class="conteiner">
<div class="esq caixa">Caixa 1 - esq</div>
<div class="caixa">Caixa 2</div>
<div class="caixa">Caixa 3</div>
</div>
<div class="conteiner">
<div class="caixa dir">Caixa 4 - dir</div>
<div class="caixa">Caixa 5</div>
<div class="caixa">Caixa 6</div>
</div>
<div class="conteiner">
<div class="caixa esq">Caixa 7 - esq</div>
<div class="caixa dir">Caixa 8 - dir</div>
<div class="caixa">Caixa 9</div>
</div>
</body>
Profª. Elisabete da Silva Santos 16
FATEC-SP
Folhas de Estilo
Para criar uma caixa com os cantos arredondados, crie duas figuras com cantos arredondados,
uma para ser utilizada como imagem de plano de fundo na parte superior da caixa e a outra na
parte inferior.
A cor das figuras deve ser igual à cor de plano de fundo da caixa. A largura da caixa deve ser
igual a largura da imagem.
Ex: top.jpg
bottom.jpg
Exemplo 26.2.2.1:
<head>
<style>
.box {width:307px;
background:gray url(bottom.jpg) no-repeat left bottom;
}
.box h3 {background:url(top.jpg) no-repeat left top;
padding: 10px 20px 0px 20px;
}
.box p {padding: 0px 0px 10px 20px;
}
</style>
</head>
<body>
<div class="box">
<h3> Título do texto </h3> teste
<p> Texto do parágrafo <br>
Texto do parágrafo <br>
Texto do parágrafo <br>
</p>
</div>
</body>
Menu deslizante é um conjunto de “links” formatados como caixas, que se deslocam com a
passagem do mouse sobre eles. O deslizamento se dá pela alteração da margem do link, criando
um recuo quando o usuário passa com o ponteiro do mouse sobre ele.
No exemplo abaixo, foi adicionado uma imagem de segundo plano na situação “visited”, alinhada
à direita da caixa, para indicar link já visitado.
Exemplo 26.3.1:
<style>
body {background:rgb(253,253,187);
}
a {display:block; width: 6em;
color:white; text-decoration:none;
border-bottom:white solid 1px;
font-size:1em; line-height:15px;
padding:0.2em; text-align:center;
background:violet;
}
Profª. Elisabete da Silva Santos 17
FATEC-SP
Folhas de Estilo
<body>
<a href="pag1.html"> link1 </a>
<a href="pag2.html"> link2 </a>
<a href="pag3.html"> link3 </a>
<a href="pag4.html"> link4 </a>
</body>
27. Filtros
Efeitos visuais apareceram pela primeira vez como controles de ActiveX e posteriormente foram
incorporados como propriedades de Folhas de Estilo aceitas inicialmente pelo browser Internet
Explorer v4.0.
Efeitos anteriormente que só poderiam ser criados com aplicativos como o Photoshop em
arquivos de imagem agora podem ser usados em qualquer objeto HTML, como por exemplos
bloco de texto, tabelas, links, bordas etc e inclusive criar efeitos dinâmicos!!
Eles são fáceis de aprender e basicamente sua sintaxe é a seguinte:
Onde nome define o tipo de filtro, parâmetro define suas propriedades de formatação e valor,
suas unidades que geralmente são graus, pixels, %, etc.
A seguir, será apresentada uma relação de filtros em ordem alfabética, bem como seus
parâmetros e alguns exemplos interessantes. Você pode aplicar diversos filtros em um mesmo
objeto, criando uma variedade de efeitos conforme manda a sua imaginação.
Obs.: Para executar os exemplos fornecidos nesta apostila, escolha imagens coloridas, do tipo
.jpg (fotografia) e .gif (desenho).
O filtro Alpha cria um efeito de transparência total ou parcial no objeto por ele envolvido, de forma
que quanto menor for a sua graduação de porcentagem, definida por opacity=%, maior será a
sua transparência.
Parâmetros:
Propriedades Descrição / Opções
Opacity Apresenta o grau de transparência do objeto e seu valor refere-se a %.
Opacity=100 apresenta um objeto totalmente opaco e opacity=0 um objeto
totalmente invisível.
FinishOpacity Define o nível de opacidade e seus valores vão de 0 a 100%.
Style Seus estilos podem ser 0 (uniforme), 1 (linear), 2 (radial) ou 3 Retangular.
StartX Coordenada horizontal para começo do gradiente de opacidade.
StartY Coordenada vertical para começo do gradiente de opacidade.
FinishX Coordenada horizontal para o fim do gradiente de opacidade.
FinishX Coordenada vertical para o fim do gradiente de opacidade.
Nos exemplos a seguir, formatamos um texto em azul e incluímos uma imagem colorida.
Aplicaremos neles diversos graus de opacidade com estilos diferentes, testados no I.E.
<body text="blue">
<h1> TEXTO E IMAGEM SEM FILTRO </h1>
<img src="imagem1.gif">
Exemplo 27.1.1. Alpha Uniforme:
O filtro Blur cria um efeito difuso diminuindo a definição das bordas do objeto. Sua sombra
apresenta a mesma cor do objeto, porém com uma textura mais atenuada.
Profª. Elisabete da Silva Santos 19
FATEC-SP
Folhas de Estilo
Parâmetros:
Propriedades Descrição / Opções
Add Parâmetro booleano, 1 Sombreamento nítido, 0 Sombreamento difuso.
Direction Define o ângulo em que o efeito deve acontecer.
Seu valor vai de 0 (topo) em incrementos de 45 graus até 315 graus.
Strength Define o comprimento que o efeito deve ter. Default = 5.
O filtro Chroma torna uma cor específica do objeto transparente. No exemplo a seguir, a imagem
imagem1.gif possui um fundo branco, que cria um contraste com o background da página.
Porém, com o filtro chroma, o fundo branco (#FFFFFF) da imagem pode ser neutralizado
simulando uma imagem GIF de fundo transparente.
Parâmetros:
Propriedade Descrição
color Define uma cor do código RGB que sofrerá o efeito de transparência.
obs.: O filtro não funcionará se a cor selecionada para o efeito não existir na figura.
O filtro Dropshadow cria um eleito de sombra sólida no objeto, que pode ser direcionada
conforme o ângulo desejado.
Parâmetros:
Propriedades Descrição / Opções
Color Define a cor RGB (#rrggbb) da sombra. Os valores são em hexadecimal.
Offx Determina a distância de afastamento em "x" (horizontal).
Os valores em pixels (px) podem ser positivos ou negativos.
Offy Determina a distância de afastamento em "y" (vertical).
Os valores em pixels (px) podem ser positivos ou negativos.
Positive Parâmetro booleano: 1 para sombra positiva. 0 para sombra negativa.
<div style="filter:dropshadow(color=#1e90ff,offx=-3,offy=-3,
positive=1); height:1">
<h1> FILTRO DROPSHADOW </h1>
<img src="imagem1.gif">
</div>
Obs.: Embora esse filtro possa ser aplicado em qualquer objeto, ele apresentará um melhor
resultado em fontes ou imagens com fundos transparentes ou vazados.
O filtro Fliph cria no objeto um efeito de imagem invertida no sentido horizontal, como o reflexo
de um espelho.
O filtro Flipv cria no objeto um efeito de imagem invertida no sentido vertical, como o reflexo
na superfície de um lago.
O filtro Glow cria um efeito de borramento nos contornos do objeto. Este borramento pode
assumir uma cor diferente do objeto. No exemplo a seguir, o objeto possui bordas brancas e o
texto está escrito em preto, no entanto, seu borramento é azul (color=#0000FF).
Parâmetros:
Propriedades Descrição / Opções
Color Define a cor RGB (#rrggbb) do borramento.
Strength Determina a distância de afastamento do efeito. Seu valor é em pixels (px) e
pode ser valor positivo (borramento externo) ou negativo (borramento interno).
<body>
<div style="filter:glow(color=#0000FF, strength=10); height:1">
<h1> FILTRO GLOW </h1>
<img src="imagem1.gif">
</div>
<body text=”red”>
<div style="filter:gray; height:1">
<h1> FILTRO GRAY </h1>
<img src="imagem1.gif">
</div>
O filtro Invert tem a propriedade de inverter a matriz de cores do objeto criando um efeito
semelhante ao negativo de uma fotografia.
<body text=”red”>
<div style="filter:invert; height:1">
<h1> FILTRO INVERT </h1>
<img src="imagem1.gif">
</div>
Parâmetros:
Propriedades Descrição / Opções
Strenght Define o comprimento do efeito, seu valor é em pixels.
Direction Define o grau em que o efeito deve ocorrer.
Ele pode ser de 0 a 360 graus.
progid:DXImageTransform.Microsoft Parâmetros proprietários da Microsoft.
No exemplo a seguir, repare que as imagens com efeito Motion Blur sofrem uma deslocação
no sentido do movimento que o efeito causou. Isso acontece porque o efeito passa a fazer parte
da imagem alterando o seu centro de equilíbrio.
<div
style="filter:progid:DXImageTransform.Microsoft.MotionBlur(strength=40,
direction=30);
height:1; ">
<h1> FILTRO MOTION BLUR </h1>
<img src="imagem1.gif">
</div>
Parâmetros:
Propiedades Descrição / Opções
add Parâmetro booleano: 1 cria o efeito wave, 0 anula o efeito.
freq Define o número de ondulações que o objeto deve sofrer.
lightstrength Define a intensidade de ondulação luminosa. Seu valor vai de 0 a 100%.
phase Define a freqüência da ondulação, seu valor vai de 0 a 360graus.
strength Define a intensidade da ondulação da imagem.
O filtro Xray cria um efeito semelhante ao filtro Gray transformando as cores do objeto em tons
de cinza só que em negativo.
Para inserir um ícone na barra de endereço de alguns navegadores e também em sua guia (aba),
faça a “chamada” da imagem através do link abaixo a partir do cabeçalho da página HTML,
atribuindo o valor “shortcut icon” à propriedade rel da tag link.
<head>
<link rel="shortcut icon" href="icone1.ico">
</head>
Muitos recursos ainda são oferecidos em termos de estilização de páginas, alguns podem ser
aprendidos através de livros, Internet...
Mas a criatividade ainda impera! Ela não tem limites!
Portanto, se você gostou, os próximos passos agora é com você.
E boa caminhada!
30. Bibliografia
Adrian Kingsley-Hughes
Kathie Kingsley-Hughes
Michael Moncur
Ano1 - nº 04
31. Tutoriais
http://www.w3.org/TR/REC-CSS1-961217
http://www.w3.org/1999/REC-CSS1-19990111
http://www.w3.org/TR/REC-CSS1
http://orbita.starmedia.com/~edaurelio/css.htm (2001/2004)
W3C: The number in the "W3C" column indicates in which CSS recommendation the property is
defined (CSS1 or CSS2).
BACKGROUND
Property Description Values IE F N W3C
background A shorthand property for background-color 4 1 6 1
setting all background background-image
properties in one background-repeat
declaration background-
attachment
background-position
background- Sets whether a background scroll 4 1 6 1
attachment image is fixed or scrolls fixed
with the rest of the page
background-color Sets the background color color-rgb 4 1 4 1
of an element color-hex
color-name
transparent
background-image Sets an image as the url 4 1 4 1
background none
background-position Sets the starting position of top left 4 1 6 1
a background image top center
top right
center left
center center
center right
bottom left
bottom center
bottom right
x-% y-%
x-pos y-pos
background-repeat Sets if/how a background repeat 4 1 4 1
image will be repeated repeat-x
repeat-y
no-repeat
BORDER
Property Description Values IE F N W3C
border A shorthand property for border-width 4 1 4 1
setting all of the properties border-style
for the four borders in one border-color
declaration
Profª. Elisabete da Silva Santos 25
FATEC-SP
Folhas de Estilo
BORDER (Cont.)
Property Description Values IE F N W3C
border-bottom-color Sets the color of the bottom border-color 4 1 6 2
border
border-bottom-style Sets the style of the bottom border-style 4 1 6 2
border
border-bottom-width Sets the width of the thin 4 1 4 1
bottom border medium
thick
length
border-color Sets the color of the four color 4 1 6 1
borders, can have from one
to four colors
border-left A shorthand property for border-left-width 4 1 6 1
setting all of the properties border-style
for the left border in one border-color
declaration
border-left-color Sets the color of the left border-color 4 1 6 2
border
border-left-style Sets the style of the left border-style 4 1 6 2
border
border-left-width Sets the width of the left thin 4 1 4 1
border medium
thick
length
border-right A shorthand property for border-right-width 4 1 6 1
setting all of the properties border-style
for the right border in one border-color
declaration
border-right-color Sets the color of the right border-color 4 1 6 2
border
border-right-style Sets the style of the right border-style 4 1 6 2
border
border-right-width Sets the width of the right thin 4 1 4 1
border medium
thick
length
border-style Sets the style of the four none 4 1 6 1
borders, can have from one hidden
to four styles dotted
dashed
solid
double
groove
ridge
inset
outset
border-top A shorthand property for border-top-width 4 1 6 1
setting all of the properties border-style
for the top border in one border-color
declaration
BORDER (Cont.)
Property Description Values IE F N W3C
border-top-color Sets the color of the top border-color 4 1 6 2
border
CLASSIFICATION
Property Description Values IE F N W3C
clear Sets the sides of an left 4 1 4 1
element where other right
floating elements are not both
allowed none
cursor Specifies the type of cursor url 4 1 6 2
to be displayed auto
crosshair
default
pointer
move
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
text
wait
help
display Sets how/if an element is none 4 1 4 1
displayed inline
block
list-item
run-in
compact
marker
table
inline-table
table-row-group
table-header-group
CLASSIFICATION (Cont.)
Property Description Values IE F N W3C
display (cont.) Sets how/if an element is table-footer-group 4 1 4 1
displayed table-row
table-column-group
table-column
table-cell
table-caption
float Sets where an image or a left 4 1 4 1
text will appear in another right
element none
position Places an element in a static 4 1 4 2
static, relative, absolute or relative
fixed position absolute
fixed
visibility Sets if an element should visible 4 1 6 2
be visible or invisible hidden
collapse
DIMENSION
Property Description Values IE F N W3C
height Sets the height of an auto 4 1 6 1
element length
%
line-height Sets the distance between normal 4 1 4 1
lines number
length
%
max-height Sets the maximum height none - 1 6 2
of an element length
%
max-width Sets the maximum width of none - 1 6 2
an element length
%
min-height Sets the minimum height of length - 1 6 2
an element %
min-width Sets the minimum width of length - 1 6 2
an element %
width Sets the width of an auto 4 1 4 1
element %
length
FONT
Property Description Values IE F N W3C
Font A shorthand property for font-style 4 1 4 1
setting all of the properties font-variant
for a font in one declaration font-weight
font-size/line-height
font-family
FONT (Cont.)
Property Description Values IE F N W3C
Font (cont.) A shorthand property for caption 4 1 4 1
setting all of the properties icon
for a font in one declaration menu
message-box
small-caption
status-bar
font-family A prioritized list of font family-name 3 1 4 1
family names and/or generic-family
generic family names for an
element
font-size Sets the size of a font xx-small 3 1 4 1
x-small
small
medium
large
x-large
xx-large
smaller
larger
length
%
font-size-adjust Specifies an aspect value none - - - 2
for an element that will number
preserve the x-height of the
first-choice font
font-stretch Condenses or expands the normal - - - 2
current font-family wider
narrower
ultra-condensed
extra-condensed
condensed
semi-condensed
semi-expanded
expanded
extra-expanded
ultra-expanded
font-style Sets the style of the font normal 4 1 4 1
italic
oblique
font-variant Displays text in a small- normal 4 1 6 1
caps font or a normal font small-caps
font-weight Sets the weight of a font normal 4 1 4 1
bold
bolder
lighter
100
200
300
400
500
600
700
FONT (Cont.)
Property Description Values IE F N W3C
font-weight (cont.) Sets the weight of a font 800 4 1 4 1
900
GENERATED CONTENT
Property Description Values IE F N W3C
content Generates content in a string 1 6 2
document. Used with the url
:before and :after pseudo- counter(name)
elements counter(name, list-
style-type)
counters(name, string)
counters(name, string,
list-style-type)
attr(X)
open-quote
close-quote
no-open-quote
no-close-quote
counter-increment Sets how much the counter none 2
increments on each identifier number
occurrence of a selector
counter-reset Sets the value the counter none 2
is set to on each identifier number
occurrence of a selector
quotes Sets the type of quotation none - 1 6 2
marks string string
MARGIN
Property Description Values IE F N W3C
margin A shorthand property for margin-top 4 1 4 1
setting the margin margin-right
properties in one margin-bottom
declaration margin-left
margin-bottom Sets the bottom margin of auto 4 1 4 1
an element length
%
margin-left Sets the left margin of an auto 3 1 4 1
element length
%
margin-right Sets the right margin of an auto 3 1 4 1
element length
%
margin-top Sets the top margin of an auto 3 1 4 1
element length
%
OUTLINES
Property Description Values IE F N W3C
outline A shorthand property for outline-color - 1.5 - 2
setting all the outline outline-style
properties in one outline-width
declaration
outline-color Sets the color of the outline color - 1.5 - 2
around an element invert
outline-style Sets the style of the outline none - 1.5 - 2
around an element dotted
dashed
solid
double
groove
ridge
inset
outset
OUTLINES (Cont.)
outline-width Sets the width of the outline thin - 1.5 - 2
around an element medium
thick
length
PADDING
Property Description Values IE F N W3C
padding A shorthand property for padding-top 4 1 4 1
setting all of the padding padding-right
properties in one padding-bottom
declaration padding-left
padding-bottom Sets the bottom padding of length 4 1 4 1
an element %
POSITIONING
Property Description Values IE F N W3C
bottom Sets how far the bottom auto 5 1 6 2
edge of an element is %
above/below the bottom length
edge of the parent element
clip Sets the shape of an shape 4 1 6 2
element. The element is auto
clipped into this shape, and
displayed
left Sets how far the left edge auto 4 1 4 2
of an element is to the %
right/left of the left edge of length
the parent element
overflow Sets what happens if the visible 4 1 6 2
content of an element hidden
overflow its area scroll
auto
position Places an element in a static 4 1 4 2
static, relative, absolute or relative
fixed position absolute
fixed
right Sets how far the right edge auto 5 1 6 2
of an element is to the %
left/right of the right edge of length
the parent element
POSITIONING (Cont.)
Property Description Values IE F N W3C
top Sets how far the top edge auto 4 1 4 2
of an element is %
above/below the top edge length
of the parent element
vertical-align Sets the vertical alignment baseline 4 1 4 1
of an element sub
super
top
text-top
middle
bottom
text-bottom
length
%
z-index Sets the stack order of an auto 4 1 6 2
element number
TABLE
Property Description Values IE F N W3C
border-collapse Sets the border model of a collapse 5 1 7 2
table separate
border-spacing Sets the distance between length length - 1 6 2
the borders of adjacent
cells (only for the
"separated borders" model)
caption-side Sets the position of the top - 1 6 2
caption according to the bottom
table left
right
empty-cells Sets whether cells with no show - 1 6 2
visible content should have hide
borders or not (only for the
"separated borders" model)
table-layout Sets the algorithm used to auto 5 1 6 2
lay out the table fixed
TEXT
Property Description Values IE F N W3C
color Sets the color of a text color 3 1 4 1
direction Sets the text direction ltr 6 1 6 2
rtl
letter-spacing Increase or decrease the normal 4 1 6 1
space between characters length
text-align Aligns the text in an left 4 1 4 1
element right
center
justify
TEXT (Cont.)
Property Description Values IE F N W3C
text-decoration Adds decoration to text none 4 1 4 1
underline
overline
line-through
blink
text-indent Indents the first line of text length 4 1 4 1
in an element %
text-shadow none
color
length
text-transform Controls the letters in an none 4 1 4 1
element capitalize
uppercase
lowercase
unicode-bidi normal 5 2
embed
bidi-override
white-space Sets how white space normal 5 1 4 1
inside an element is pre
handled nowrap
word-spacing Increase or decrease the normal 6 1 6 1
space between words length
PSEUDO-CLASSES
Pseudo-class Purpose IE F N W3C
:active Adds special style to an activated element 4 1 8 1
:focus Adds special style to an element while the element - - - 2
has focus
:hover Adds special style to an element when you mouse 4 1 7 1
over it
:link Adds special style to an unvisited link 3 1 4 1
:visited Adds special style to a visited link 3 1 4 1
:first-child Adds special style to an element that is the first 1 7 2
child of some other element
:lang Allows the author to specify a language to use in a 1 8 2
specified element
PSEUDO-ELEMENTS
Pseudo-element Purpose IE F N W3C
:first-letter Adds special style to the first letter of a text 5 1 8 1
:first-line Adds special style to the first line of a text 5 1 8 1
:before Inserts some content before an element 1.5 8 2
:after Inserts some content after an element 1.5 8 2