Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why wont background-color work in html 5 using the <header> tag?

Tags:

html

here is my html for some reason the header tag isnt accepting the background color for black..

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="keywords" content=""/>
<meta name="description" content="" /> 


<style type="text/css">
    header {
        background:black;
    }

    nav ul li {
        float:left;
        margin-left:20px;
        display:block;
    }

    nav ul li {
        text-transform:capitalize;
        padding:5px 0px;
    }
</style>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

</head>
<body>
    <header>
    <nav>
        <ul>
            <li><a href="index.php">today's deals</a></li>
            <li><a href="recent.php">recent deals</a></li>

        </ul>
    <div class="clear"></div>       
    </nav>
    </header>

</body>
</html>
like image 331
Exploit Avatar asked Dec 09 '10 04:12

Exploit


People also ask

How do you put a background color on a header in HTML?

To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.

How do I change the background color of my header?

Go to the Design tab. Click Customize to expand the set of choices for customizing your theme. Click Header Image to choose an image to be the background of the header. Click Header background to choose a color for the header section.

What is the correct HTML for adding a background color in HTML?

The attribute that is used to set background color of an HTML element is bg color. Depending on the element whose background color is to be set, we use the appropriate tag. The bgcolor attribute can be used with the following tags- body, table, td, th, tr, marquee.

Which tag is used for giving background Colour?

To set the background color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <body> tag, with the CSS property background-color.


2 Answers

I've got it! I know it's been a while, but I was having the same problem. You must remember to apply width and height attributes to the header or it will not work.

header {
background-color: black;
display: block;
width: 960px;
height: 300px;
}

I had the same problem, because the background only covered paragraph or other tags, not the whole area.

like image 74
alexharriss Avatar answered Sep 28 '22 02:09

alexharriss


have you tried

 background-color:black;

well it could be it's not supported still

this worked for me

   header {
        background-color:black;
    display:block;
    overflow:hidden;
    }

for thoose browsers that do support it i guess why nothing wasn't displayed at first glance it's because the default behaviour isn't using it as a regular element rather then making the page more seo friendly

like image 41
Breezer Avatar answered Sep 28 '22 00:09

Breezer