2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Prioritize One Style Over Another
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Prioritize One Style Over Another
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Problem Explanation
|
2018-11-18 07:20:03 +04:00
|
|
|
We need to create a CSS class called ```pink-text``` that gives an our ```h1``` element the color pink.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
|
|
|
|
|
|
|
Between ```<style>``` and ```</style>``` create a class called ```pink-text```:
|
2018-11-18 07:20:03 +04:00
|
|
|
|
|
|
|
```css
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
background-color: black;
|
|
|
|
font-family: monospace;
|
|
|
|
color: green;
|
|
|
|
}
|
|
|
|
.pink-text {
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|
2019-07-24 00:59:27 -07:00
|
|
|
```
|
|
|
|
And add in this class ```color``` with value of ```pink```:
|
2018-11-18 07:20:03 +04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
```css
|
2018-11-18 07:20:03 +04:00
|
|
|
.pink-text {
|
|
|
|
color: pink;
|
|
|
|
}
|
2019-07-24 00:59:27 -07:00
|
|
|
```
|
2018-11-18 07:20:03 +04:00
|
|
|
After, add this class to our ```h1``` element:
|
|
|
|
|
|
|
|
```css
|
|
|
|
<h1 class="pink-text">Hello World!</h1>
|
|
|
|
```
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
**Full solution**
|
2018-11-18 07:20:03 +04:00
|
|
|
|
|
|
|
```css
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
background-color: black;
|
|
|
|
font-family: monospace;
|
|
|
|
color: green;
|
|
|
|
}
|
|
|
|
.pink-text {
|
|
|
|
color: pink;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<h1 class="pink-text">Hello World!</h1>
|
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
</details>
|