---
id: bad87fee1348bd9aedf07756
title: Override All Other Styles by using Important
challengeType: 0
videoUrl: ''
localeTitle: 使用重要覆盖所有其他样式
---
## Description
好极了!我们刚刚证明了内联样式将覆盖style
元素中的所有CSS声明。可是等等。有一种覆盖CSS的最后一种方法。这是所有人中最强大的方法。但在我们这样做之前,让我们谈谈为什么你想要覆盖CSS。在许多情况下,您将使用CSS库。这些可能会意外地覆盖您自己的CSS。所以当你绝对需要确定一个元素有特定的CSS时,你可以使用!important
让我们一直回到我们的pink-text
类声明。请记住,我们的pink-text
类被后续的类声明,id声明和内联样式覆盖。
## Instructions
让我们在粉红色文本元素的颜色声明中添加关键字!important
,以100%确定你的h1
元素是粉红色的。如何执行此操作的示例是: color: red !important;
## Tests
```yml
tests:
- text: 您的h1
元素应该具有pink-text
类。
testString: 'assert($("h1").hasClass("pink-text"), "Your h1
element should have the class pink-text
.");'
- text: 你的h1
元素应该有blue-text
。
testString: 'assert($("h1").hasClass("blue-text"), "Your h1
element should have the class blue-text
.");'
- text: 您的h1
元素应具有orange-text
的ID。
testString: 'assert($("h1").attr("id") === "orange-text", "Your h1
element should have the id of orange-text
.");'
- text: '您的h1
元素应具有内联样式的color: white
。'
testString: 'assert(code.match(/h1 element should have the inline style of color: white
.");'
- text: 你的pink-text
类声明应该有!important
关键字来覆盖所有其他声明。
testString: 'assert(code.match(/\.pink-text\s*?\{[\s\S]*?color:.*pink.*!important\s*;?[^\.]*\}/g), "Your pink-text
class declaration should have the !important
keyword to override all other declarations.");'
- text: 你的h1
元素应该是粉红色的。
testString: 'assert($("h1").css("color") === "rgb(255, 192, 203)", "Your h1
element should be pink.");'
```
## Challenge Seed
## Solution
```js
// solution required
```