“Light red” and “light green” background colors not working-CSS

  • Context: HTML/CSS 
  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Green
Click For Summary

Discussion Overview

The discussion revolves around issues with CSS background colors, specifically the use of "light red" and "light green" in a coding assignment from The Odin Project. Participants explore the correct syntax and potential errors in the CSS code provided.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant shares their CSS code and notes that "light red" and "light green" are not working as expected.
  • Another participant suggests that the issue may be due to the space in "light green," proposing that it should be written as "lightgreen."
  • A third participant confirms that "lightpink" and "lightgreen" work, implying that the syntax issue is likely the cause of the original problem.
  • Additional comments emphasize the importance of using proper HTML and CSS formatting for clarity and readability.
  • One participant recommends using a modern code editor like Visual Studio Code to help identify mistakes in the code.

Areas of Agreement / Disagreement

Participants generally agree that the space in "light green" is likely the source of the issue, but there is no consensus on the broader implications of using color names in CSS.

Contextual Notes

There are limitations regarding the assumptions about color naming conventions in CSS and the specific context of the coding assignment that may not be fully addressed.

shivajikobardan
Messages
637
Reaction score
54
TL;DR
light red and light green background colors not working.
https://github.com/TheOdinProject/css-exercises/tree/main/foundations/02-class-id-selectors

I’m doing this assignment of The Odin Project. But the two colors aren’t working.
Here’s my code:
index.html:

Code:
<p class="odd">Number 1 - I'm a class!</p>
    <div ids="second">Number 2 - I'm one ID.</div>
    <p class="odd oddly-cool">Number 3 - I'm a class, but cooler!</p>
    <div id="four">Number 4 - I'm another ID.</div>
    <p class="odd">Number 5 - I'm a class!</p>

Style.css:
Code:
.odd{
    background-color: light red;
    font-family: Verdana, Dejavu Sans, sans-serif;
}
 
#second{
    color:blue;
    font-size:36px;
}
 
.oddly-cool{
    font-size:24px;
}
 
.four{
    background-color: light green;
    font-size:24px;
    font-weight: 700;
 
}

If I put rgb value, it will work though. So, what’s the issue? Doesnt’ background-color supports light as a value?
 
Technology news on Phys.org
thank you. lightpink works and lightgreen.
 
  • Like
Likes   Reactions: jedishrfu
HTML:
<h1>It's not hard to start HTML code with a [code=html] tag.</h1>
<!-- It makes code much easier to read. -->
<p>
  <strong style="color: red">Don't be lazy</strong>, help others to help you.
  <small>You can also select HTML as the language in the "Insert code" dialog.</small>
</p>

CSS:
/* It's not hard to start CSS code with a [code=css] tag.
 * It makes code much easier to read.
 * **Don't be lazy**, help others to help you.
 */
:root {
  --warning-color: rgb(255, 0, 0);
}
.warning {
  color: var(--warning-color);
}
 /*  You can also select CSS as the language in the "Insert code" dialog. */
 
  • Like
Likes   Reactions: Wrichik Basu
You should also use a modern code editor such as Visual Studio Code which will often highlight mistakes: this is what it looks like:
1667377191086.png
 
  • Like
Likes   Reactions: jedishrfu and Mark44

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 13 ·
Replies
13
Views
7K
  • · Replies 20 ·
Replies
20
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K