CSS - background


Advertisements


Description

background is a shorthand element used to set background styles for an element.

Possible Values

background is a shorthand property and stand for the following. This value will vary depending on actual property.

  • background-color − Sets a solid color for the element's background, padding, and border background.

  • background-image − Defines the location of an image to be placed in the element's back- ground.

  • background-repeat − Sets a repeat direction for an image in the element's background.

  • background-attachment − Sets an attachment state for any images in the element's background.

  • background-position − Sets a position for the origin image in the element's background.

  • background-clip − Specifies the painting area of the background images

Applies to

All the HTML elements.

DOM Syntax

object.style.background = "Value according to the used property";

Example

<html>
   <head>
   </head>
   <body>
      <p style="background:url(/images/pattern1.gif) repeat fixed;">
      This parapgraph has fixed repeated background image. 
      This parapgraph has fixed repeated background image. 
      This parapgraph has fixed repeated background image. 
      This parapgraph has fixed repeated background image.
      </p>
   </body>
</html> 

It will produce the following result −



Advertisements