Values
<length>

+または-(デフォルトでは+)の直後に正負の記号のない整数または実数が続き、直後に以下の単位識別子(2文字省略形)のいずれかが続く。「 0 」の後の単位識別子は任意。

  • em: the 'font-size' of the relevant font
  • ex: the 'x-height' of the relevant font
  • px: pixels, relative to the viewing device
  • in: inches -- 1in = 2.54cm
  • cm: centimeters
  • mm: millimeters
  • pt: points -- 72pt = 1in
  • pc: picas -- 1pc = 12pt
<color>
CSS1で定義されているキーワード

aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow

CSS2で追加されたキーワード

ActiveBorder, ActiveCaption, AppWorkspace, Background, ButtonFace, ButtonHighlight, ButtonShadow, ButtonText, CaptionText, GrayText, Highlight, HighlightText, InactiveBorder, InactiveCaption, InactiveCaptionText, InfoBackground, InfoText, Menu, MenuText, Scrollbar, ThreeDDarkShadow, ThreeDFace, ThreeDHighlight, ThreeDLightShadow, ThreeDShadow, Window, WindowFrame, WindowText

RGBによる表記
#f00 /* #rgb */
#ff0000 /* #rrggbb */
rgb(255,0,0)
rgb(100%, 0%, 0%) }
<uri>

url(URI), url( URI ), url("URI"), url( "URI" ), url('URI'), url( 'URI' )などが可能。URI中の括弧「 ( ) 」, コンマ「 , 」, 空白類文字, アポストロフィー「 ' 」, 引用符「 " 」は、引用するかバックスラッシュでエスケープしなければならない。

以下の指定は等価。ただし、2番目をきちんと認識するUAは少ない。

  1. url( "UR I" )
  2. url( UR\ I )
CSS property definitions
Value
A B C
複数の値が並記されている場合、順番通りに全て。
A | B | C
1本線で区切られている場合、そのうち一つだけ。
A || B || C
2本線で区切られている場合、順不同で少なくとも一つ。
{ }
グループ化。
*
0回以上の繰り返し。
+
1回以上の繰り返し。
?
0回または1回。
{A, B}
A回以上B回以下の繰り返し。
font-family

CSS1CSS2
Value: [[<family-name> | <generic-family>],]* [<family-name> | <generic-family>] [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
Initial:UA specificdepends on user agent
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
<generic-family>
font-style

CSS1CSS2
Value:normal | italic | obliquenormal | italic | oblique | inherit
Initial:normalnormal
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
font-variant

CSS1CSS2
Value:normal | small-capsnormal | small-caps | inherit
Initial:normalnormal
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
font-weight

CSS1CSS2
Value: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
Initial:normalnormal
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
font-size

CSS1CSS2
Value:<absolute-size> | <relative-size> | <length> | <percentage><absolute-size> | <relative-size> | <length> | <percentage> | inherit
Initial:mediummedium
Applies to:all elementsall elements
Inherited:yesyes, the computed value is inherited
Percentages:relative to parent element's font sizerefer to parent element's font size
Media:
visual
<absolute-size>
[ xx-small | x-small | small | medium | large | x-large | xx-large ]
<relative-size>
[ larger | smaller ]

次のように、画像にfont-sizeを設定しても問題ない。全ての要素に有効。

font-size: 10pt;margin-left: 1em
font-size: 50pt;margin-left: 1em
font

CSS1CSS2
Value:[ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'>[ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'> ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
Initial:not defined for shorthand propertiessee individual properties
Applies to:all elementsall elements
Inherited:yesyes
Percentages:allowed on 'font-size' and 'line-height'allowed on 'font-size' and 'line-height'
Media:
visual

CSS2では、システムフォントも指定できる。システムフォントにはファミリやウェイトといった情報も含まれていて、定義からもstyle="font: bold caption"のような指定はできない。ただし、style="font: caption;font-weight: bold"とするなら可。

WinIE4/5はシステムフォントをサポートしていることになっているが、caption | icon | menu | messagebox | smallcaption | statusbarと間違えて実装している。

color

CSS1CSS2
Value:<color><color> | inherit
Initial:UA specificdepends on user agent
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
background-color

CSS1CSS2
Value:<color> | transparent<color> | transparent | inherit
Initial:transparenttransparent
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
background-image

CSS1CSS2
Value: <uri> | none<uri> | none | inherit
Initial:nonenone
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
background-repeat

CSS1CSS2
Value:repeat | repeat-x | repeat-y | no-repeatrepeat | repeat-x | repeat-y | no-repeat | inherit
Initial:repeatrepeat
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
background-attachment

CSS1CSS2
Value:scroll | fixedscroll | fixed | inherit
Initial:scrollscroll
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
background-position

CSS1CSS2
Value:[<percentage> | <length>]{1,2} | [top | center | bottom] || [left | center | right][ [<percentage> | <length> ]{1,2} | [ [top | center | bottom] || [left | center | right] ] ] | inherit
Initial:0% 0%0% 0%
Applies to:block-level and replaced elementsblock-level and replaced elements
Inherited:nono
Percentages:refer to the size of the element itselfrefer to the size of the box itself
Media:
visual
キーワードによる指定
指定1指定2指定3解釈
top leftleft top
0% 0%
toptop centercenter top50% 0%
right toptop right
100% 0%
leftleft centercenter left0% 50%
centercenter center
50% 50%
rightright centercenter right100% 50%
bottom leftleft bottom
0% 100%
bottombottom centercenter bottom50% 100%
bottom rightright bottom
100% 100%
background

CSS1CSS2
Value:<'background-color'> || <'background-image'> || <'background-repeat'> || <'background-attachment'> || <'background-position'>[<'background-color'> || <'background-image'> || <'background-repeat'> || <'background-attachment'> || <'background-position'>] | inherit
Initial:not defined for shorthand propertiesnot defined for shorthand properties
Applies to:all elementsall elements
Inherited:nono
Percentages:allowed on 'background-position'allowed on 'background-position'
Media:
visual
word-spacing

CSS1CSS2
Value:normal | <length>normal | <length> | inherit
Initial:normalnormal
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
letter-spacing

CSS1CSS2
Value:normal | <length>normal | <length> | inherit
Initial:normalnormal
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
text-decoration

CSS1CSS2
Value:none | [ underline || overline || line-through || blink ]none | [ underline || overline || line-through || blink ] | inherit
Initial:nonenone
Applies to:all elementsall elements
Inherited:no, but see clarification belowno (see prose)
Percentages:N/AN/A
Media:
visual
vertical-align

CSS1CSS2
Value:baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage>baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage> | <length> | inherit
Initial:baselinebaseline
Applies to:inline elementsinline-level and 'table-cell' elements
Inherited:nono
Percentages:refer to the 'line-height' of the element itselfrefer to the 'line-height' of the element itself
Media:
visual

CSS2では、vertical-align属性に長さを指定できる。0はbaselineと同じ。

<SPAN style="vertical-align: 1em">vertical</SPAN>-<SPAN style="vertical-align: -1em">align</SPAN> → vertical-align
text-transform

CSS1CSS2
Value: capitalize | uppercase | lowercase | none capitalize | uppercase | lowercase | none | inherit
Initial:nonenone
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
text-align

CSS1CSS2
Value:left | right | center | justifyleft | right | center | justify | <string> | inherit
Initial:UA specificdepends on user agent and writing direction
Applies to:block-level elementsblock-level elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual

<string>という値は、セル要素にのみ有効。指定した文字列を基準軸にして、書字方向に従いセルの内容を配列する。

セルの内容に指定した文字列が含まれていない場合、内容の終端が基準軸に接する。セルの内容が複数行の挙動は未定義。

書式表示表示テスト
TD { text-align: "." }
   
<TABLE>
<TR><TD>1.50
<TR><TD>10.5
<TR><TD>105.05
<TR><TD>55.
<TR><TD>50
<TR><TD>.05
</TABLE>
  1.50
 10.5
105.05
 55.
 50
   .05
1.50
10.5
105.05
55.
50
.05
text-indent

CSS1CSS2
Value: <length> | <percentage><length> | <percentage> | inherit
Initial:00
Applies to:block-level elementsblock-level elements
Inherited:yesyes
Percentages:refer to parent element's widthrefer to width of containing block
Media:
visual
line-height

CSS1CSS2
Value:normal | <number> | <length> | <percentage>normal | <number> | <length> | <percentage> | inherit
Initial:normalnormal
Applies to:all elementsall elements
Inherited:yesyes
Percentages:relative to the font size of the element itselfrefer to the font size of the element itself
Media:
visual
margin-top, margin-right, margin-bottom, margin-left

CSS1CSS2
Value:<length> | <percentage> | auto<length> | <percentage> | auto | inherit
Initial:00
Applies to:all elementsall elements
Inherited:nono
Percentages:refer to width of the closest block-level ancestorrefer to width of containing block
Media:
visual

CSS2では、紙面などのページ媒体への出力モデル(@page規則)が導入されている。その規則内では、%で指定した垂直方向のマージン計算法が異なる。

margin

CSS1CSS2
Value:[ <length> | <percentage> | auto ]{1,4}[ <length> | <percentage> | auto ]{1,4} | inherit
Initial:not defined for shorthand propertiesnot defined for shorthand properties
Applies to:all elementsall elements
Inherited:nono
Percentages:refer to width of closest block-level ancestorrefer to width of containing block
Media:
visual
padding-top, padding-right, padding-bottom, padding-left

CSS1CSS2
Value:<length> | <percentage><length> | <percentage> | inherit
Initial:00
Applies to:all elementsall elements
Inherited:nono
Percentages:refer to width of closest block-level ancestorrefer to width of containing block
Media:
visual
padding

CSS1CSS2
Value:[ <length> | <percentage> ]{1,4}[ <length> | <percentage> ]{1,4} | inherit
Initial:not defined for shorthand propertiesnot defined for shorthand properties
Applies to:all elementsall elements
Inherited:nono
Percentages:refer to width of closest block-level ancestorrefer to width of containing block
Media:
visual
border-top-width, border-right-width, border-bottom-width, border-left-width

CSS1CSS2
Value:thin | medium | thick | <length>thin | medium | thick | <length> | inherit
Initial:'medium'medium
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
border-width

CSS1CSS2
Value:[thin | medium | thick | <length>]{1,4}[thin | medium | thick | <length>]{1,4} | inherit
Initial:not defined for shorthand propertiessee individual properties
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
border-color

CSS1CSS2
Value: <color>{1,4} [ <color> | transparent ]{1,4} | inherit
Initial:the value of the 'color' propertysee individual properties
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual

border-color属性値をtransparentに設定すると、幅はあるが透明な状態になる。

<DIV style="border-style: solid;border-color: transparent"></DIV>
border-style

CSS1CSS2
Value:none | dotted | dashed | solid | double | groove | ridge | inset | outset[none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset]{1,4} | inherit
Initial:nonesee individual properties
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual

定義をみると、CSS1では一つの値しか指定できないが、一つ以上四つ以下値を指定できると解説されている。

hiddenという値はnoneとほぼ同じではあるが、境界の競合が生じた場合の優先順位が異なる。

border-top, border-right, border-bottom, border-left

CSS1CSS2
Value: <bordr-width> || <border-style> || <color> [ <border-top-width> || <border-style> || [<color> | transparent] | inherit
Initial:not defined for shorthand propertiessee individual properties
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
border

CSS1CSS2
Value:<border-width> || <border-style> || <color>[ <border-width> || <border-style> || [<color> | transparent] ] | inherit
Initial:not defined for shorthand propertiessee individual properties
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
width

CSS1CSS2
Value:<length> | <percentage> | auto<length> | <percentage> | auto | inherit
Initial:autoauto
Applies to:block-level and replaced elementsall elements but non-replaced inline elements, table rows, and row groups
Inherited:nono
Percentages:refer to parent element's widthrefer to width of containing block
Media:
visual
height

CSS1CSS2
Value:<length> | auto<length> | <percentage> | auto | inherit
Initial:autoauto
Applies to:block-level and replaced elementsall elements but non-replaced inline elements, table columns, and column groups
Inherited:nono
Percentages:N/Asee prose
Media:
visual

CSS2では、ブロックレベル, 置換要素の内容の高さを、%でも指定できる。参照するのは、包含ブロックの高さ。非置換インライン要素の高さは、line-height属性で決まる(非置換インライン要素のマージン, 境界, パディングは、行の高さに影響を及ぼさない)。

float

CSS1CSS2
Value:left | right | noneleft | right | none | inherit
Initial:nonenone
Applies to:all elementsall but positioned elements and generated content
Inherited:nono
Percentages:N/AN/A
Media:
visual
clear

CSS1CSS2
Value:none | left | right | bothnone | left | right | both | inherit
Initial:nonenone
Applies to:all elementsblock-level elements
Inherited:nono
Percentages:N/AN/A
Media:
visual
display

CSS1CSS2
Value:block | inline | list-item | noneinline | block | list-item | run-in | compact | marker | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit
Initial:blockinline
Applies to:all elementsall elements
Inherited:nono
Percentages:N/AN/A
Media:
all

compactという値は、要素をコンパクトボックスにする。浮動せず、絶対配置でもないブロックボックスがコンパクトボックスに続くとき、日本語なら後に続くブロックボックスの左マージンと比較して、一行で収まるのであればコンパクトボックスはマージン領域にインラインボックスとして配置される。そうでなければ、コンパクトボックスはブロックボックスになる。

書式表示表示テスト
DT { display: compact }
DD { margin-left: 2em }

<DL>
<DT>ok
<DD>Description
<DT>too long
<DD>Description
</DL>
ok  Description
too long
    Description
ok
Description
too long
Description

run-inという値は、要素をランインボックスにする。浮動せず、絶対配置でもないブロックボックスがランインボックスに続くとき、ランインボックスは後に続くブロックボックスの最初のインラインボックスになる。そうでなければ、ランインボックスはブロックボックスになる。

ランイン要素における継承は、視覚的にその一部となったブロック要素ではなく、本来の親から行われる。

書式表示表示テスト
H3 { display: run-in }

<H3>見出し</H3>
<P>段落のテキスト</P>
見出し 段落のテキスト

見出し

段落のテキスト

inline-tableという値は、要素をインラインの表にする。

書式表示テスト
TABLE.inline { 
  display: inline-table;
  margin: 0.5em;
}
ヘッダヘッダ
データデータ
ヘッダヘッダ
データデータ
white-space

CSS1CSS2
Value:normal | pre | nowrapnormal | pre | nowrap | inherit
Initial:normalnormal
Applies to:all elementsall elements
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
list-style-type

CSS1CSS2
Value:disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | nonedisc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-alpha | lower-latin | upper-alpha | upper-latin | hebrew | armenian | georgian | cjk-ideographic | hiragana | katakana | hiragana-iroha | katakana-iroha | none | inherit
Initial:discdisc
Applies to:elements with 'display' value 'list-item'elements with 'display: list-item'
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
表示テスト
  1. disc
  2. circle
  3. square
  4. decimal
  5. lower-roman
  6. upper-roman
  7. lower-alpha
  8. upper-alpha
  9. none
  1. decimal-leading-zero (01, 02, 03)
  2. lower-greek (έ, ή, ί)
  3. lower-latin (=lower-alpha)
  4. upper-latin (=upper-alpha)
  5. hebrew (Alef, Bet, ...)
  6. armenian
  7. georgian
  8. cjk-ideographic (一、二、三)
  9. hiragana (あ、い、う)
  10. katakana (ア、イ、ウ)
  11. hiragana-iroha (い、ろ、は)
  12. katakana-iroha (イ、ロ、ハ)

list-style-image

CSS1CSS2
Value:<uri> | none<uri> | none | inherit
Initial:nonenone
Applies to:elements with 'display' value 'list-item'elements with 'display: list-item'
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
list-style-position

CSS1CSS2
Value:inside | outsideinside | outside | inherit
Initial:outsideoutside
Applies to:elements with 'display' value 'list-item'elements with 'display: list-item'
Inherited:yesyes
Percentages:N/AN/A
Media:
visual
list-style

CSS1CSS2
Value:[ <'list-style-type'> ] || [ <'list-style-position'> ] || [ <'list-style-image'> ][ <'list-style-type'> || <'list-style-position'> || <'list-style-image'> ] | inherit
Initial:not defined for shorthand propertiesnot defined for shorthand properties
Applies to:elements with 'display' value 'list-item'elements with 'display: list-item'
Inherited:yesyes
Percentages:N/AN/A
Media:
visual