To create a colored square in HTML, you typically use a <div> element styled with CSS to set equal width and height properties, along with a background-color. For example:
<div style="width: 100px; height: 100px; background-color: red;"></div>Alternatively, you can use HTML Unicode symbols to insert pre-defined square shapes directly into your text without CSS. Common examples include:
■ (U+25A0) – Black Square
□ (U+25A1) – White Square
▣ (U+25A3) – White Square Containing Black Small Square
◼ (U+25FC) – Black Medium Square
🟥 (U+1F7E5) – Large Red Square (color-specific)
These symbols can be inserted using their HTML entity codes (e.g., ■ for ■) or directly if your editor supports Unicode input.
To create a square border around text, wrap the text in a <span> or <div> and apply CSS:
.square-box {
display: inline-flex;
width: 50px;
height: 50px;
align-items: center;
justify-content: center;
border: 2px solid #333;
box-sizing: border-box;
}<span class="square-box">Text</span>For list bullets, use the CSS property list-style-type: square; on an unordered list (<ul>).
Try next:
.box {
float: left;
height: 20px;
width: 20px;
margin-bottom: 15px;
border: 1px solid black;
clear: both;
}
.red {
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
<div><div class='box red'></div>= Super Fast Trains</div>
<br>
<div><div class='box green'></div>= Mail/Express Trains</div>
<br>
<div><div class='box blue'></div>= Local/ Passenger Trains</div>
Answer from Max Wolfen on Stack OverflowVideos
Try next:
.box {
float: left;
height: 20px;
width: 20px;
margin-bottom: 15px;
border: 1px solid black;
clear: both;
}
.red {
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
<div><div class='box red'></div>= Super Fast Trains</div>
<br>
<div><div class='box green'></div>= Mail/Express Trains</div>
<br>
<div><div class='box blue'></div>= Local/ Passenger Trains</div>
How about using the square html entity?
<div style="color:blue">■</div>
this is how to make squares
<div id="square"></div>
#square {
width: 100px;
height: 100px;
background: red;
}
hope that helps source: https://css-tricks.com/examples/ShapesOfCSS/
For Html squares pls try as below
<div id="squares">
<div id="square1"></div>
<div id="square2"></div>
<div id="square3"></div>
</div>
and CSS as below
#squares div {
/* these styles will let the divs line up next to each other
while accepting dimensions */
display: block;
float: left;
width: 150px;
height: 150px;
/* a small margin to separate the blocks */
margin-right: 5px;
}
#square1 { background: red;}
#square2 { background: black;}
#square3 { background: yellow;}
Put those characters after the text you want or your can use <sup> tag around 2.
2²
2<sup>2</sup>
This is called Superscript and actually there is a special HTML element just for this task: <sup>
You simply need to wrap your desired text inside <sup></sup>
Here's an example:
<span>my<sup>text</sup></span>