- 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は少ない。
- url( "UR I" )
- 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回以下の繰り返し。
- <generic-family>
-
- serif
- sans-serif
- cursive
- fantasy
- monospace
font-style
| CSS1 | CSS2 |
| Value: | normal | italic | oblique | normal | italic | oblique | inherit |
| Initial: | normal | normal |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
font-variant
| CSS1 | CSS2 |
| Value: | normal | small-caps | normal | small-caps | inherit |
| Initial: | normal | normal |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
font-weight
| CSS1 | CSS2 |
| Value: |
normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit |
| Initial: | normal | normal |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| 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

CSS2では、システムフォントも指定できる。システムフォントにはファミリやウェイトといった情報も含まれていて、定義からもstyle="font: bold caption"のような指定はできない。ただし、style="font: caption;font-weight: bold"とするなら可。
- <SPAN style="font: caption">caption</SPAN> → ボタンやドロップダウン
- <SPAN style="font: icon">icon</SPAN> → アイコン
- <SPAN style="font: menu">menu</SPAN> → メニュー
- <SPAN style="font: message-box">message-box</SPAN> → メッセージボックス
- <SPAN style="font: small-caption">small-caption</SPAN> → スモールキャプション
- <SPAN style="font: status-bar">status-bar</SPAN> → ステータスバー
WinIE4/5はシステムフォントをサポートしていることになっているが、caption | icon | menu | messagebox | smallcaption | statusbarと間違えて実装している。
- <SPAN style="font: messagebox">messagebox</SPAN> → メッセージボックス
- <SPAN style="font: smallcaption">smallcaption</SPAN> → スモールキャプション
- <SPAN style="font: statusbar">statusbar</SPAN> → ステータスバー
color
| CSS1 | CSS2 |
| Value: | <color> | <color> | inherit |
| Initial: | UA specific | depends on user agent |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
background-color
| CSS1 | CSS2 |
| Value: | <color> | transparent | <color> | transparent | inherit |
| Initial: | transparent | transparent |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
background-image
| CSS1 | CSS2 |
| Value: |
<uri> | none | <uri> | none | inherit |
| Initial: | none | none |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
background-repeat
| CSS1 | CSS2 |
| Value: | repeat | repeat-x | repeat-y | no-repeat | repeat | repeat-x | repeat-y | no-repeat | inherit |
| Initial: | repeat | repeat |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
background-attachment
| CSS1 | CSS2 |
| Value: | scroll | fixed | scroll | fixed | inherit |
| Initial: | scroll | scroll |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
background-position
| CSS1 | CSS2 |
| 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 elements | block-level and replaced elements |
| Inherited: | no | no |
| Percentages: | refer to the size of the element itself | refer to the size of the box itself |
| Media: |
| visual |
- キーワードによる指定
-
| 指定1 | 指定2 | 指定3 | 解釈 |
| top left | left top |
| 0% 0% |
| top | top center | center top | 50% 0% |
| right top | top right |
| 100% 0% |
| left | left center | center left | 0% 50% |
| center | center center |
| 50% 50% |
| right | right center | center right | 100% 50% |
| bottom left | left bottom |
| 0% 100% |
| bottom | bottom center | center bottom | 50% 100% |
| bottom right | right bottom |
| 100% 100% |
word-spacing
| CSS1 | CSS2 |
| Value: | normal | <length> | normal | <length> | inherit |
| Initial: | normal | normal |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
letter-spacing
| CSS1 | CSS2 |
| Value: | normal | <length> | normal | <length> | inherit |
| Initial: | normal | normal |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
text-decoration
| CSS1 | CSS2 |
| Value: | none | [ underline || overline || line-through || blink ] | none | [ underline || overline || line-through || blink ] | inherit |
| Initial: | none | none |
| Applies to: | all elements | all elements |
| Inherited: | no, but see clarification below | no (see prose) |
| Percentages: | N/A | N/A |
| Media: |
| visual |
vertical-align
| CSS1 | CSS2 |
| 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: | baseline | baseline |
| Applies to: | inline elements | inline-level and 'table-cell' elements |
| Inherited: | no | no |
| Percentages: | refer to the 'line-height' of the element itself | refer 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
| CSS1 | CSS2 |
| Value: |
capitalize | uppercase | lowercase | none |
capitalize | uppercase | lowercase | none | inherit |
| Initial: | none | none |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
text-align
| CSS1 | CSS2 |
| Value: | left | right | center | justify | left | right | center | justify | <string> | inherit |
| Initial: | UA specific | depends on user agent and writing direction |
| Applies to: | block-level elements | block-level elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/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
| CSS1 | CSS2 |
| Value: |
<length> | <percentage> | <length> | <percentage> | inherit |
| Initial: | 0 | 0 |
| Applies to: | block-level elements | block-level elements |
| Inherited: | yes | yes |
| Percentages: | refer to parent element's width | refer to width of containing block |
| Media: |
| visual |
line-height
| CSS1 | CSS2 |
| Value: | normal | <number> | <length> | <percentage> | normal | <number> | <length> | <percentage> | inherit |
| Initial: | normal | normal |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | relative to the font size of the element itself | refer to the font size of the element itself |
| Media: |
| visual |
margin-top, margin-right, margin-bottom, margin-left
| CSS1 | CSS2 |
| Value: | <length> | <percentage> | auto | <length> | <percentage> | auto | inherit |
| Initial: | 0 | 0 |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | refer to width of the closest block-level ancestor | refer to width of containing block |
| Media: |
| visual |
CSS2では、紙面などのページ媒体への出力モデル(@page規則)が導入されている。その規則内では、%で指定した垂直方向のマージン計算法が異なる。
margin
| CSS1 | CSS2 |
| Value: | [ <length> | <percentage> | auto ]{1,4} | [ <length> | <percentage> | auto ]{1,4} | inherit |
| Initial: | not defined for shorthand properties | not defined for shorthand properties |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | refer to width of closest block-level ancestor | refer to width of containing block |
| Media: |
| visual |
padding
| CSS1 | CSS2 |
| Value: | [ <length> | <percentage> ]{1,4} | [ <length> | <percentage> ]{1,4} | inherit |
| Initial: | not defined for shorthand properties | not defined for shorthand properties |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | refer to width of closest block-level ancestor | refer to width of containing block |
| Media: |
| visual |
border-width
| CSS1 | CSS2 |
| Value: | [thin | medium | thick | <length>]{1,4} | [thin | medium | thick | <length>]{1,4} | inherit |
| Initial: | not defined for shorthand properties | see individual properties |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
border-color
| CSS1 | CSS2 |
| Value: |
<color>{1,4} |
[ <color> | transparent ]{1,4} | inherit |
| Initial: | the value of the 'color' property | see individual properties |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
border-color属性値をtransparentに設定すると、幅はあるが透明な状態になる。
<DIV style="border-style: solid;border-color: transparent"></DIV>
border-style
| CSS1 | CSS2 |
| Value: | none | dotted | dashed | solid | double | groove | ridge | inset | outset | [none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset]{1,4} | inherit |
| Initial: | none | see individual properties |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
定義をみると、CSS1では一つの値しか指定できないが、一つ以上四つ以下値を指定できると解説されている。
hiddenという値はnoneとほぼ同じではあるが、境界の競合が生じた場合の優先順位が異なる。
border-top, border-right, border-bottom, border-left
| CSS1 | CSS2 |
| Value: |
<bordr-width> || <border-style> || <color> |
[ <border-top-width> || <border-style> || [<color> | transparent] | inherit |
| Initial: | not defined for shorthand properties | see individual properties |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
- <border-width>: thin | medium | thick | <length>
- <border-style>: none | dotted | dashed | solid | double | groove | ridge | inset | outset | hidden (CSS2)
border
| CSS1 | CSS2 |
| Value: | <border-width> || <border-style> || <color> | [ <border-width> || <border-style> || [<color> | transparent] ] | inherit |
| Initial: | not defined for shorthand properties | see individual properties |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
- <border-width>: thin | medium | thick | <length>
- <border-style>: none | dotted | dashed | solid | double | groove | ridge | inset | outset | hidden (CSS2)
width
| CSS1 | CSS2 |
| Value: | <length> | <percentage> | auto | <length> | <percentage> | auto | inherit |
| Initial: | auto | auto |
| Applies to: | block-level and replaced elements | all elements but non-replaced inline elements, table rows, and row groups |
| Inherited: | no | no |
| Percentages: | refer to parent element's width | refer to width of containing block |
| Media: |
| visual |
height
| CSS1 | CSS2 |
| Value: | <length> | auto | <length> | <percentage> | auto | inherit |
| Initial: | auto | auto |
| Applies to: | block-level and replaced elements | all elements but non-replaced inline elements, table columns, and column groups |
| Inherited: | no | no |
| Percentages: | N/A | see prose |
| Media: |
| visual |
CSS2では、ブロックレベル, 置換要素の内容の高さを、%でも指定できる。参照するのは、包含ブロックの高さ。非置換インライン要素の高さは、line-height属性で決まる(非置換インライン要素のマージン, 境界, パディングは、行の高さに影響を及ぼさない)。
float
| CSS1 | CSS2 |
| Value: | left | right | none | left | right | none | inherit |
| Initial: | none | none |
| Applies to: | all elements | all but positioned elements and generated content |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
clear
| CSS1 | CSS2 |
| Value: | none | left | right | both | none | left | right | both | inherit |
| Initial: | none | none |
| Applies to: | all elements | block-level elements |
| Inherited: | no | no |
| Percentages: | N/A | N/A |
| Media: |
| visual |
display
| CSS1 | CSS2 |
| Value: | block | inline | list-item | none | inline | 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: | block | inline |
| Applies to: | all elements | all elements |
| Inherited: | no | no |
| Percentages: | N/A | N/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
| CSS1 | CSS2 |
| Value: | normal | pre | nowrap | normal | pre | nowrap | inherit |
| Initial: | normal | normal |
| Applies to: | all elements | all elements |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
list-style-type
| CSS1 | CSS2 |
| Value: | disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | none | disc | 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: | disc | disc |
| Applies to: | elements with 'display' value 'list-item' | elements with 'display: list-item' |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
- 表示テスト
-
- disc
- circle
- square
- decimal
- lower-roman
- upper-roman
- lower-alpha
- upper-alpha
- none
- decimal-leading-zero (01, 02, 03)
- lower-greek (έ, ή, ί)
- lower-latin (=lower-alpha)
- upper-latin (=upper-alpha)
- hebrew (Alef, Bet, ...)
- armenian
- georgian
- cjk-ideographic (一、二、三)
- hiragana (あ、い、う)
- katakana (ア、イ、ウ)
- hiragana-iroha (い、ろ、は)
- katakana-iroha (イ、ロ、ハ)
list-style-image
| CSS1 | CSS2 |
| Value: | <uri> | none | <uri> | none | inherit |
| Initial: | none | none |
| Applies to: | elements with 'display' value 'list-item' | elements with 'display: list-item' |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |
list-style-position
| CSS1 | CSS2 |
| Value: | inside | outside | inside | outside | inherit |
| Initial: | outside | outside |
| Applies to: | elements with 'display' value 'list-item' | elements with 'display: list-item' |
| Inherited: | yes | yes |
| Percentages: | N/A | N/A |
| Media: |
| visual |