OBSAH
1 Umiestnenie v HTML
2 Definície štýlov
2.1 Pseudotriedy
3 Formátovanie blokov
4 Fonty
5 Farba
6 Vlastnosti textu
7 Dĺžkové jednotky
<HTML> <HEAD> <TITLE>title</TITLE> <LINK REL=STYLESHEET TYPE="text/css" HREF="http://style.com/cool" TITLE="Cool" MEDIA="print"> <STYLE TYPE="text/css"> @import url(http://style.com/basic); H1 { color: blue } </STYLE> </HEAD> <BODY> <H1>Headline is blue</H1> <P STYLE="color: green">While the paragraph is green.</P> </BODY> </HTML>
<SELECTOR> { [ <VLASTNOSŤ> : <HODNOTA> ; ]* }Selektor je jedna alebo viacero HTML značiek, ktoré môžu byť upresnené triedou alebo identifikátorom:
BODY { background: white url(pozadie.jpg); color: #008; font: bold large arial }Jednotlivé definície sú oddelené bodkočiarkami, ak je viac hodnôt pre jeden atribút, sú zvyčajne oddelené medzerami.
/****** Oddeľovačom pseudotriedy je dvojbodka! ******/ A:link { color: red } /* nenavštívená linka */ A:visited { color: blue } /* navštívená linka */ A:active { color: lime } /* aktívna (kliknutá) linka */ P:first-line { font-variant: small-caps } /* ovplyvní prvý riadok */ P:first-letter { font-size: 200%; float: left } /* ovplyvní prvý znak */Pseudotrieda môže byť kombinovaná s normálnou triedou, pričom pseudotrieda sa vždy uvádza za normálnou triedou. V kombinovanom selektore môže byť použitý odkaz len na jednu pseudotriedu:
A.external:visited { color: blue }
UL {background: red; margin: A B C D; border-width: E F G H; padding: I J K L; } margin-top, margin-right, margin-bottom, margin-left, margin{1,4}: auto | <length> | <percentage> padding-top, padding-right, padding-bottom, padding-left, padding{1,4}: <length> | <percentage> border-top-width, border-right-width, border-bottom-width, border-left-width, border-width{1,4}: thin | medium | thick | <length> border-color: <color>{1,4} border-style{1,4}: none | dotted | dashed | solid | | double | groove | ridge | inset | outset border-top, border-right, border-bottom, border-left: <border-<dir>-width> || <border-style> || <color> border: <border-width> || <border-style> || <color> /* border nastavuje vždy naraz všetky štyri okraje! */ width: auto | <length> | <percentage> height: auto | <length> display: block | inline | list-item | none white-space: normal | pre | nowrap list-style-type: disc | circle | square | decimal | lower-roman | upper-roman | | lower-alpha | upper-alpha | none list-style-image: none | <url> list-style-position: outside | inside list-style: [disc | circle | square | decimal | lower-roman | upper-roman | | lower-alpha | upper-alpha | none] || [inside | outside] || || [<url> | none] UL { list-style: outside | inside }Nastavenie atribútu float spôsobí, že vybraný objekt sa presunie vľavo (vpravo) a okolitý text ho bude obtekať. Je vždy zarovnaný na vrch riadku. Atribút clear pre text spôsobí, že text bude zobrazený až pod príslušnými float objektami.
float: none | left | right clear: none | left | right | both
font-family: [[ <family-name> | <generic-family> ],]* 'serif' (e.g. Times) 'sans-serif' (e.g. Helvetica) 'cursive' (e.g. Zapf-Chancery) 'fantasy' (e.g. Western) 'monospace' (e.g. Courier) font-style: normal | italic | oblique font-variant: normal | small-caps font-weight: normal | bold | bolder | lighter | 100 | 200 | 300 | | 400 | 500 | 600 | 700 | 800 | 900 normal == 400 bold == 700 font-size: <absolute-size> | <relative-size> | <length> | <percentage> <absolute-size> = xx-small | x-small | small | medium | large | x-large | xx-large <relative-size> = larger | smaller <length> = 1.5em | 2ex <percentage> = 150% font: [ <font-style> || <font-variant> || <font-weight> ]? <font-size> [ / <line-height> ]? <font-family>Font-families sa oddeľujú čiarkou! Prehliadač vyberie prvý, ktorý má k dispozícii.
color: transparent | #$$$$$$ | #$$$ | rgb(r,g,b) | rgb(r%,g%,b%) | <MENO>
<MENO> - | Black | = "#000000" | Green | = "#008000" | |||
Silver | = "#C0C0C0" | Lime | = "#00FF00" | ||||
Gray | = "#808080" | Olive | = "#808000" | ||||
White | = "#FFFFFF" | Yellow | = "#FFFF00" | ||||
Maroon | = "#800000" | Navy | = "#000080" | ||||
Red | = "#FF0000" | Blue | = "#0000FF" | ||||
Purple | = "#800080" | Teal | = "#008080" | ||||
Fuchsia | = "#FF00FF" | Aqua | = "#00FFFF" |
background-color: transparent | <color> background-image: none | <url> background-repeat: repeat | repeat-x | repeat-y | no-repeat background-attachment: scroll | fixed /* či sa pozadie posúva s textom */ background-position: [<percentage> | <length>]{1,2} | | [top | center | bottom] || [left | center | right] background: <background-color> || <background-image> || <background-repeat> || <background-attachment> || <background-position>
word-spacing: normal | <length> letter-spacing: normal | <length> text-decoration: none | [ underline || overline || line-through || blink ] vertical-align: baseline | sub | super | top | text-top | middle | | bottom | text-bottom | <percentage> text-transform: none | capitalize | uppercase | lowercase text-align: left | right | center | justifyOdsadenie prvého riadku:
text-indent: <length> | <percentage> line-height: normal | <number> | <length> | <percentage>