2018-09-30 23:01:58 +01:00
---
id: bad87fee1348bd9aedf08756
title: Prioritize One Style Over Another
challengeType: 0
videoUrl: 'https://scrimba.com/c/cZ8wnHv'
2019-07-31 11:32:23 -07:00
forumTopicId: 18258
2021-01-13 03:31:00 +01:00
dashedName: prioritize-one-style-over-another
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
Sometimes your HTML elements will receive multiple styles that conflict with one another.
2020-11-27 19:02:05 +01:00
For example, your `h1` element can't be both green and pink at the same time.
Let's see what happens when we create a class that makes text pink, then apply it to an element. Will our class *override* the `body` element's `color: green;` CSS property?
# --instructions--
Create a CSS class called `pink-text` that gives an element the color pink.
Give your `h1` element the class of `pink-text` .
# --hints--
Your `h1` element should have the class `pink-text` .
```js
assert($('h1').hasClass('pink-text'));
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
Your `<style>` should have a `pink-text` CSS class that changes the `color` .
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;\s*\}/g));
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Your `h1` element should be pink.
```js
assert($('h1').css('color') === 'rgb(255, 192, 203)');
```
# --seed--
## --seed-contents--
2018-09-30 23:01:58 +01:00
```html
< style >
body {
background-color: black;
font-family: monospace;
color: green;
}
< / style >
< h1 > Hello World!< / h1 >
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
2020-07-13 18:58:50 +02:00
```html
2019-02-17 11:41:48 -05:00
< style >
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
< / style >
< h1 class = "pink-text" > Hello World!< / h1 >
2018-09-30 23:01:58 +01:00
```