Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to add a white square to the header of an HTML Bootstrap 5 website is by using CSS to create a square-shaped div element with a white background color and positioning it within the header element. Here is an example:

HTML:

<header>
  <div class="white-square"></div>
  <!-- other header content goes here -->
</header>

CSS:

.white-square {
  width: 50px;
  height: 50px;
  background-color: white;
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

In this example, the CSS code creates a div element with a width and height of 50 pixels and a white background color. It is positioned absolutely within the header element using the top and left properties, and is centered vertically using the transform property. Adjust the width, height, and position properties as necessary to suit your website design.