--- id: bad87fee1348bd9aedf07756 title: Important 的優先級最高 challengeType: 0 videoUrl: 'https://scrimba.com/c/cm24rcp' forumTopicId: 18249 dashedName: override-all-other-styles-by-using-important --- # --description-- 耶! 我們剛剛又證明了行內樣式會覆蓋 `style` 標籤裏面所有的 CSS 聲明。 不過, 還有一種方式可以覆蓋重新 CSS 樣式。 這是所有方法裏面最強大的一個。 在此之前,我們要考慮清楚,爲什麼我們要覆蓋 CSS 樣式。 很多時候,你會使用 CSS 庫, CSS 庫中的樣式會意外覆蓋你的 CSS 樣式。 如果想保證你的 CSS 樣式不受影響,你可以使用 `!important`。 讓我們回到 `pink-text` 類聲明。 `pink-text` 類的顏色樣式已被之後的 class 聲明、id 聲明以及行內樣式所覆蓋。 # --instructions-- 給粉紅文本元素的顏色聲明添加關鍵詞 `!important`,以確保 `h1` 元素爲粉紅色。 如下所示: ```css color: red !important; ``` # --hints-- `h1` 元素應包含 `pink-text` class。 ```js assert($('h1').hasClass('pink-text')); ``` `h1` 元素應包含 `blue-text` class。 ```js assert($('h1').hasClass('blue-text')); ``` `h1` 元素應有 `id`, 值爲 `orange-text`。 ```js assert($('h1').attr('id') === 'orange-text'); ``` `h1` 元素應有一個內聯樣式 `color: white`。 ```js assert(code.match(/