---
id: bad87fee1348bd9aedf06756
challengeType: 0
videoUrl: 'https://scrimba.com/c/cGJDRha'
forumTopicId: 18252
title: 内联样式的优先级高于 ID 选择器
---
## Description
我们刚刚证明了,id 选择器无论在style
标签哪里声明,都会覆盖 class 声明的样式,
其实还有其他方法可以覆盖重写 CSS 样式。你还记得行内样式吗?
## Instructions
使用行内样式尝试让h1
的字体颜色变白。像下面这样使用:
<h1 style="color: green">
h1
元素需继续保留blue-text
和pink-text
class。
## Tests
```yml
tests:
- text: 'h1
元素应该包含pink-text
class。'
testString: assert($("h1").hasClass("pink-text"));
- text: 'h1
元素应该包含blue-text
class。'
testString: assert($("h1").hasClass("blue-text"));
- text: 'h1
元素应该包含一个名为orange-text
的id。'
testString: assert($("h1").attr("id") === "orange-text");
- text: 'h1
元素应该含有行内样式。'
testString: assert(document.querySelector('h1[style]'));
- text: 'h1
元素的字体颜色应该为白色。'
testString: assert($("h1").css("color") === "rgb(255, 255, 255)");
```
## Challenge Seed
## Solution
```html
// solution required
```