Tutorials

KodeKite Tools

HTML
Flexbox
SVG
Canvas
HTML Tutorial

More


HTML Background
Background

HTML background is used to style background of any html page or element. It uses CSS to apply styles like background color, background image etc.


  • Background Color
  • Background Image
Background Color

Background color is used to apply color in background of HTML page or element by using colors.

Syntax

background-color:color;


You can apply any color to html element or document.


Example

Heading 1

Background Image

Background image is used to apply image in background of html page or any element.

Syntax

background-image:url(URL);


You can use any image type like jpg, jpeg, png or even gif.


Example


You can apply background image to any HTML element. For more background properties visit our CSS Background.


Note:

Remember it is not neccessary that background image is olny gievn in body of HTML page, you can give background image to any HTML element like in above example it is given to div element.


Practice Task

Open notepad or any other text editor, follow the following points.


  • define any HTML element
  • Give width and height of 200px and 100px to element respectivelly
  • Apply background image to element

save file with name task.html or task.htm and then open it using any browser and see results.


Solution

Heading 1