Problem with div id, or it wont make background gray

I used to work in notepad and there I make this:

<div id="div">

<h1>this is heading</h1>
<p>this is paragraph</p>


#div{background-color: gray;}


when I open it in browser it makes div gray, heading and paragraph together, but now when I am using A pen I do the same:

<div id="background color">
<h1=>Dr. Norman Borlaug</h1>
<p>The man who saved a bilion lives</p>
#background color {gray

and it wont work, can anyone help, thank you

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

I’m seeing a bunch of issues with your second code snippet:

An id cannot have a space in it.

This is a malformed html tag.

This is not valid CSS.
Is this just in your HTML? Or is it in a CSS section?
As mentioned, identifiers can’t have spaces.

The name of your id can’t contain spaces in it. Try using “background-color” or “background_color” instead.


#background-color {
  background-color: gray;


<div id="background-color">
some code here...
1 Like

thank you! this solved a problem

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.