Course Content
HTML Introduction
0/1
HTML Editors
0/1
HTML Basic Tags
0/1
HTML Elements
0/1
HTML Attributes
0/1
HTML Headings
0/1
HTML Paragraph
0/1
HTML Text Formatting
0/1
HTML Meta Tags
0/1
HTML Quotations
0/1
HTML Comments
0/1
HTML Images
0/1
HTML Background
0/1
HTML Colors
0/1
HTML Lists
0/1
HTML Tables
0/1
HTML Forms
0/1
HTML Spell Check
0/1
HTML Media
0/1
HTML Marquees
0/1
HTML CSS
0/1
HTML Links
0/1
HTML Block & Inline
0/1
HTML Classes
0/1
HTML Id
0/1
HTML I frames
0/1
HTML Java script
0/1
HTML File paths
0/1
HTML Layout
0/1
HTML Responsive
0/1
HTML Computer Code
0/1
HTML Tutorial
About Lesson

HTML Background

In this tutorial, we will learn about background color and background images in HTML with the help of examples.


Background

By default, the webpage background color is white.

Html provides two attributes for the background :

  • Bg-color
  • Background

bgcolor Attribute

  • The bgcolor attribute is designed to control the background of the HTML page body and table background.
  • The bgcolor attribute is not used in HTML 5.0 and later versions.

Syntax

<tag_name< span="">bgcolor = "color_value"></tag_name<>

The color value can be used in 3 different ways:

  • Color Name – blue, green, white, yellow etc
  • Hex Value – #f2f5a1, #45ab12, #a1b2c3 etc
  • RGB Value – rgb(0,0,120), rgb(150,0,80), rgb(80,90,100) etc

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>Image tag attr</title>
  </head>
  <body>
    <h3 bgcolor = "#f3a1ba">This is colored background 1.</h3>
    <h3 bgcolor = "#abd1c5">This is colored background 2.</h3>
  </body>
</html>

Output

This is colored background 1.

This is colored background 2.


background Attribute

  • The background attribute is used to control the background of an HTML element.
  • We can also specify an image to set background in HTML page.

Syntax

<tag_name background = "image URL">

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>Image tag attr</title>
  </head>
  <body>
    <h3 background = "./html.png">This is background with image</h3>
  </body>
</html>

Output

This is background with image

 

Exercise Files
No Attachment Found
No Attachment Found
error: Content is protected !!