Take the 2-minute tour ×

When I assign "background-color: foo;" to a element in my CSS file I do not get any colour. What other attributes do i need to declare, I have a absolute width set? Does it need a parent container (it has a basic as a parent)? What am I missing here?!

Also I'd like to give it round-corners using HTML5. Corners only have to work in Safari as it's for a web app not general consumption.

share|improve this question
The web is full of round-corners DIV guides. What have you tried? –  Mahmoud Al-Qudsi May 29 '12 at 4:13
What are you suggesting I try? I can post my code but it looks like the ones below, <head-scratch>. –  wide_eyed_pupil May 29 '12 at 4:30
add comment

2 Answers

up vote 5 down vote accepted

It seems you have 2 questions: 1. set background to an element; 2. you wanna set round corners to an element and works in safari.

  1. if you element is div tag, you need to set width,and height of your div tag, e.g:

    <div id='mydiv'>some elements here</div>

Your css:

   #mydiv { 
      background-color: #111;
      height: 100px;

2. Setting round-corner(code below works for all browsers):

   .round-corner {
      -webkit-border-radius: 5px 5px 5px 5px; 
      -moz-border-radius: 5px 5px 5px 5px;
      -o-border-radius: 5px 5px 5px 5px;
      border-radius: 5px 5px 5px 5px;
share|improve this answer
I want the height to be dynamic, can I leave off the height and just let the elements stretch it? –  wide_eyed_pupil May 29 '12 at 4:44
@wide_eyed_pupil: yes you can –  xbonez May 29 '12 at 5:10
add comment

Background color has to be in hex or a valid string recognizable by the browser

So, something like this:

background: #F0F0F0;


background: white;

For borders:

border-radius: 4px;


share|improve this answer
add comment

Your Answer


