Files
freeCodeCamp/curriculum/challenges/english/01-responsive-web-design/basic-css/prioritize-one-style-over-another.english.md
Randell Dawson 3ec1fe8ea7 feat: add forumTopicId to challenge frontmatter [pre-existing]
This commit adds the pre-existing challenge guide topics in the
forum to the forntmatter of their challenge markdown files.
2019-08-05 22:14:37 +05:30

1.8 KiB

id, title, challengeType, videoUrl, forumTopicId
id title challengeType videoUrl forumTopicId
bad87fee1348bd9aedf08756 Prioritize One Style Over Another 0 https://scrimba.com/c/cZ8wnHv 18258

Description

Sometimes your HTML elements will receive multiple styles that conflict with one another. 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.

Tests

tests:
  - text: Your <code>h1</code> element should have the class <code>pink-text</code>.
    testString: assert($("h1").hasClass("pink-text"));
  - text: Your <code>&#60;style&#62;</code> should have a <code>pink-text</code> CSS class that changes the <code>color</code>.
    testString: assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;\s*\}/g));
  - text: Your <code>h1</code> element should be pink.
    testString: assert($("h1").css("color") === "rgb(255, 192, 203)");

Challenge Seed

<style>
  body {
    background-color: black;
    font-family: monospace;
    color: green;
  }
</style>
<h1>Hello World!</h1>

Solution

<style>
  body {
    background-color: black;
    font-family: monospace;
    color: green;
  }
  .pink-text {
    color: pink;
  }
</style>
<h1 class="pink-text">Hello World!</h1>