FAQ: CSS Color - Foreground vs Background

This community-built FAQ covers the “Foreground vs Background” exercise from the lesson “CSS Color”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn CSS

FAQs on the exercise Foreground vs Background

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi! I realize my question is not directly related to the topic, but I think I’m missing a couple of important things here.
I noticed that the regions in index.html for this exercise has their contents (<h2>, <p> and <a>) enclosed in <li> tags. I assume that it might be that way for semantic purposes. If so, when should you do this as opposed to using combinations of other semantic tags?
For example like so:

<section>
  <article>
    <h2></h2>
    <p></p>
    <a></a>
  </article>
   .
   .
   .
  <article>
    <h2></h2>
    <p></p>
    <a></a>
  </article>
</section>

Hi, just letting you know, the first instruction doesn’t get applied, I’ve tried everything I can think of, using HEX, RGB, I even click on the solution copy paste it and nothing, the color on the h1 heading doesn’t change, the background color does though.

2 Likes

First, Codecademy’s HTML tends not to use the more semantic tags. My theory is that the courses were not updated with the release of the newer, more semantically accurate tags (like <section>, for instance).

Second, in this instance, using <li> can be considered correct as they are LISTING regions and describing them. This could also be applied to the roasting levels, IMO

3 Likes

Hi, please can I get an explanation to why color: midnight-blue; override the existing color: #41292C; for h1

Thank you very much codedcolt0961340047

Just to show how its done.

Does foreground color affect anything other than the text color?
For example, color: red; changes the text to red.
Are there any examples where color: red; change the color of anything besides the text to red?

This isn’t only happening for this lesson, but every time I enter CSS properties, when I press “run”, it tells me I didn’t enter what I was told to in the instructions. I view the solutions every time, and there is no difference between my code and the correct code.

I was curious about the usage of li element here and thanks for the explanation!

Why was I not able to change the foreground color in .header class while I was able to change it when I edited .h1 class?

In the HTML file
the header has a class header and has a h1 element in it.

I am confused.

I would think that it might be because the header class is given to the <div> that is containing the <h1> and not the <h1> it self which has it’s own declaration.