!important宣言
アセンブラの魔女 ⧫ CSS ⧫ 構文 ⧫ !important宣言
アセンブラの魔女 ⧫ CSS ⧫ 構文 ⧫ !important宣言

 !important宣言を使えば、規則適用の優先順位を最優先に設定することができます。

!important

 規則の'プロパティ:値'の後に、空白文字を置いた後、'!important'を置きます

!important宣言の例
p { text-indent: 1em ! important }
p { font-style: italic ! important }

 !important宣言は作成者のスタイルシートでもユーザーのスタイルシートでも使えますが、ユーザーのスタイルシートは作成者のスタイルシートよりも優先されます。

 !important宣言をショートハンド・プロパティに使うと、そのショートハンド・プロパティに関連付けられたすべてのプロパティに!important宣言が適用されます。例えば、ショートハンド・プロパティのfontに!important宣言を行うと、これに関連するプロパティ(font-style、font-variant、font-weight、font-size、font-height、font-family)にも!important宣言が適用されます。

ショートハンド・プロパティへの!important宣言の例
p { font: normal 12pt sans-serif !important }
▼ Property
記事情報
datePublished2011-01-01
dateModified2018-06-22
authorアセンブラの魔女
headlineCSSの!important宣言に関する記事です
keywordsCSS
keywordsCascading Style Sheets
keywords構文
keywords!important
publisher name= wiredFish, logo.name= wiredFish, logo.url= https://books-nekoya.jp/Programming/chigu-hagu-title-01.png size= 208 pixel x 50 pixel
image.url url= https://books-nekoya.jp/Programming/chigu-hagu-title-01.png , size= 208 pixel x 50 pixel