How to override css for giving background image?


Tags: html,css

Problem :

I have one page and I have applied style.css to it and in that body has given by default one background Image which will set automatically by adding css file to that page. But in that I want all formatting same but I want to change body background image.

So what I will have to do to override the css formatting ?

In style.css I have given :

body
{
     background: url(images/bg.jpg) repeat-x #e4e9ec top;
}

But I want bg.png as it's background So I have used :

<body background="images/noise-bg.png">

Is there any way ?



Solution :

Something like this should work:

<body style="background-image: url(images/noise-bg.png)">

In terms of specificity, the style attribute should be more specific than styles defined in a stylesheet.

enter image description here

You can read more about CSS specificity here: http://css-tricks.com/specifics-on-css-specificity/


    CSS Howto..

    How to visually re-order elements in a scrolling dropdown input div?

    How to maneuver between two divs using CSS?

    How to use jQueryUI tootip along with my custom css

    How to center two blocks with some gap inbetween using CSS?

    How to get content below background-image with z-index of -1?

    How to create dropdown menu that appears based on answer from another dropdown menu

    How to create vertical tabs in firefox addon?

    How to get a gradient background for table rows with JSF and CSS?

    How to make one css input type be displayed the same as another input type

    How to override the css using the JQuery

    css: How to make elements not to overlap + automatically place them in a relevant position

    ValidationSummary and ValidationMessageFor with custom CSS shown when no errors present

    How to ignore white spaces in between tags, CSS, PHP

    How to change table width using css

    How to center FontAwesome icon in css before content vertically

    How to add custom tag to a header to make the font size larger in WordPress? [closed]

    How do I move this label inside my textarea?

    How can i include label-info from twitter boostrap in my own class definition?

    CSS Nav Menu Text rare behaviour in size thats aligned bottom some how

    How do I create a navigation system like that of Lowes.com [closed]

    Transition animation to show hidden content

    jQuery hide/show issue with offset

    How to debug HTML/CSS for iPhone/iPad performance?

    Images not showing up in IE 9

    How to flip multiple divs using CSS?

    How do CSS sprites work?

    How to wrap text without whitespace? [duplicate]

    how to relocation dropdownmenu by CSS

    How to add an image to a custom CSS button

    CSS: how to add a style to everything, unless it is defined