What are the different ways to set the background color of a div

Source: Internet
Author: User
There are two ways to set the background color of the Div, one is to set the background color directly within the DIV tag, and the external CSS setting div background color, to give you a detailed explanation of these two methods today.

First, set the background color directly inside the div tag

<div style= "background: #000; Color: #FFF "> Background is black </div>

Set the background color to black in the div tag and the font color to white

div Setting Background color

Set background color inside div tag

CSS styles such as background color are set using the style set in the div tag.

Second, external CSS set div background color

This is named ". Divcss5" for an object CSS, setting the div object background color by creating an external selector

CSS code:

. divcss5{background: #F00; color: #FFF} HTML Source code: <div class= "DIVCSS5" > Background color red </div>

The way to set the background color of the div is that these two kinds, the need for friends can be saved, but also please continue to follow the site of other updates.

Related reading:

Div+css How to use


What is CSS


html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.