How to Create a box filled with a color with HTML / CSS

To create a box filled with a color with HTML / CSS, you can use the following steps:

  1. In your HTML file, create a div element that will be used to hold the colored box.
  2. Add a class or ID to the div element that you can use to style it with CSS.
  3. In your CSS file, use the class or ID of the div element to select it.
  4. Use the background-color property to set the color of the box.

For example, the following code would create a box filled with red:

<div id="my-box">This is my box</div>
#my-box {
  background-color: red;
}

The box will be filled with red and will have the text “This is my box” inside it.

You can also use the padding property to add padding to the box, and the border property to add a border around the box.

For example, the following code would create a box filled with red, with 10 pixels of padding, and a 1-pixel solid black border:

<div id="my-box">This is my box</div>
#my-box {
  background-color: red;
  padding: 10px;
  border: 1px solid black;
}

The box will be filled with red, have 10 pixels of padding, and a 1-pixel solid black border.