0

I'm trying to create a div in HTML and then in a separate style sheet. I'm giving the instruction to put a background of red on it.

For some reason, nothing is happening. Here is the code

<div id="Box">
<p class="special">Selection:</p>
<br />
<input type='submit' value='Submit' />
</div>

In my css file, I use this command

#Box   {
 background:red;;
}
NoWar
  • 36,338
  • 80
  • 323
  • 498
user1060187
  • 957
  • 5
  • 12
  • 28

6 Answers6

4

For problems like this, use a tool like Firebug to determine what CSS rules are applied to an element ("Inspect Element" in the context menu). The tools will also allow you to see all the errors which happened during page loading (for example if a CSS stylesheet could not be found) and they show all the resources which were loaded plus lots of other useful information.

See here if you are a victim of IE: Is there something like "Firebug for IE" (for debugging JavaScript)?

Chrome already comes with batteries.

Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
2

Based on the info you provided, it should work fine as seen here

Are you positive you are linking your CSS sheet correctly?

Ben
  • 764
  • 4
  • 19
0

You have two semicolons after background: red, which is causing your code to break. See this jsFiddle for the solution.

Alternatively, you could have linked your stylesheet incorrectly. You should include this between the <head> tags of your page:

 <LINK href="demo.css" rel="stylesheet" type="text/css">
jacktheripper
  • 13,953
  • 12
  • 57
  • 93
  • 1
    No, a doubled semicolon won't break CSS… The main reason will be a not-linked stylesheet. – feeela Feb 21 '12 at 17:18
0

Try removing one of the semi-colons in your CSS:

 #Box {
    background:red;
 }
Curtis
  • 101,612
  • 66
  • 270
  • 352
0

To set a background colour on your DIV, use the the CSS background-color property: http://www.w3schools.com/cssref/pr_background-color.asp

Nigel Belham
  • 463
  • 3
  • 12
0

try using background-color: Red; as the others have mentioned you also have two semi-colons

Oliver
  • 1,490
  • 18
  • 19