HTML div background image not working

D3XT3R

The HTML div for the navigation bar design in CSS will not work.

CSS

/* CSS Document */

*{
    margin: 0px;
    padding: 0px; 
}

.clear {
    clear:both;
    height:0px; 
}

body {  
    background:url(../images/bg.jpg) no-repeat scroll center top #13120d;   

    margin: 0;  
    padding: 0;     
    font-family: Tahoma;
    font-size: 13px; 
}   

#header_menu_bg {
    background: url('../images/navigation.png') no-repeat center top;
    height: 198px;  
    width: 737px; 
}

This is just a short example.

HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <meta name="robots" content="index, follow"/>
        <meta name="keywords" content="bla"/>
        <meta name="description" content="bla"/>
        <title>WEBSITE</title>

        <link rel="stylesheet" type="text/css" href="styles/main.css"/>
        <link rel="shortcut icon" href="favicon.png"/>
    </head>
    <body>
        <div id="header_menu_bg">

Any help will be much appreciated!

Pieter VDE
  1. Make sure the URL to your image is correct.
  2. Place the URL in between ' or " tags (url("../images/navigation.png"))
  3. Add a width to your div, f.e. width: 200px;

EDIT: When looking at your full HTML, you also need to close your <body> and <html> tags.

Your full code will look like this:

HTML:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="robots" content="index, follow"/>
    <meta name="keywords" content="bla"/>
    <meta name="description" content="bla"/>
    <title>WEBSITE</title>

    <link rel="stylesheet" type="text/css" href="styles/main.css"/>
    <link rel="shortcut icon" href="favicon.png"/>
</head>
<body>
    <div id="header_menu_bg"></div>
</body>
</html>

CSS:

*{
    margin: 0px;
    padding: 0px; 
}

.clear {
    clear:both;
    height:0px; 
}

body {  
    background-color: #13120d;  
    margin: 0;  
    padding: 0;     
    font-family: Tahoma;
    font-size: 13px; 
}   

#header_menu_bg {
    background: url('http://placehold.it/737x198') no-repeat center top;
    height: 198px;  
    width: 737px; 
}

DEMO: JSBin (JSFiddle doesn't seem to work at the moment)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CSS / HTML - Background image not working

From Dev

CSS/HTML background image not working

From Dev

SVG as inline background image of a Div is not working

From Dev

CSS background image for DIV not working with auto

From Dev

background-image for wrapper div is not working

From Dev

background-image transition for div on hover is not working

From Dev

Background Image opacity not working [HTML/CSS]

From Dev

HTML div background by CSS not always working

From Dev

html div background image not showing up

From Dev

Background/background image not working?

From Dev

HTML Div convert into image with background image Html2canvas

From Dev

Fixed position div in HTML sitting in front of background image of secondary div

From Dev

Html - Div Table - The background colors not working with margins, padding, border

From Dev

Remove background image not working

From Dev

Background image for a jPanel not working

From Dev

Controller background image not working

From Dev

Background image doesn't show within the <div> element - CSS/HTML

From Dev

Div Background image disappears

From Java

Fit background image to div

From Dev

Targeting background image of div

From Dev

Fixed background image for a div

From Dev

Background image flickering in a div

From Dev

Div Background image disappears

From Dev

Change background image of a div

From Dev

Fixed background image for a div

From Dev

Background Image is not displaying in Div

From Dev

background image of a div

From Dev

HTML Background Chrome not working

From Dev

background image not showing in html