Home > database >  Need to add css style block to turn all h2elements blue
Need to add css style block to turn all h2elements blue

Time:04-16

h2 {color: blue;#

Keeps telling me “Your h2 element should be blue” on freeCodeCamp

CodePudding user response:

h2 {color:blue;}

h2.red {color:red;}
<!--  h2 on css is blue-->

<h2>HELLO<h2>

<!-- use class to color h2 red-->

<h2 >This is color red</h2>

CodePudding user response:

You can do this easily with CSS.

color stands for the color of the element. This code makes all h2 elements red, and all p elements blue.

h2 { color:red; }
p { color: blue; }
<h2>this is red</h2>
<h2>this is also red</h2>
<h2>this is also red!</h2>
<p>this isn't red, it's blue :(</p>

If something has a class, or an ID and you want to color that, you can use:

.myClass {
  color: limegreen;
}
#myID {
  color: aqua;
}
<p >Class</p>
<p >Class</p>
<p id="myID">ID</p>

NOTE: You can only have one ID in a page, but you can have multiple classes in a page.

You can learn more about CSS color at:

https://www.w3schools.com/css/css_colors.asp

https://developer.mozilla.org/en-US/docs/Web/CSS/color

If you want the background color to be blue, you can do background-color: blue;, instead of color: blue;.

You can learn about background colors at https://developer.mozilla.org/en-US/docs/Web/CSS/background-color or at that w3schools page linked above.

  •  Tags:  
  • css
  • Related