How to set background for html

青灯夜游
Release: 2023-01-07 11:41:35
Original
62480 people have browsed it

htmlHow to set the background: 1. Use the bgcolor attribute of the body tag to set the background color; 2. Use the background attribute of the body tag to set the background image; 3. Use the style attribute in the body tag and add "background: Color value/url('picture path')".

How to set background for html

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

htmlSet the background

1. The bgcolor attribute of the body tag

bgcolor attribute specification document background color.

    

Hello world!

Copy after login

Rendering:

How to set background for html

#Note: If you use color names, the rendering structures of different browsers are different. If you use RGB codes, Firefox The browser cannot display the correct color.

Tip: If all browsers want to display the same color, use hexadecimal color codes.

2. The background attribute of the body tag

The background attribute specifies the background image of the document.

    
Copy after login

Rendering:

How to set background for html

3. css background attribute

The background attribute is an abbreviation Properties, you can set all background properties in one statement.

The properties that can be set are:

  • background-color

  • background-position

  • background-size

  • background-repeat

  • ##background-origin

  • background-clip

  • background-attachment

  • background-image

Example:


     

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

Copy after login
Rendering:


How to set background for html

Recommended tutorial: "

html video tutorial"

The above is the detailed content of How to set background for html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!