How To Make A Square In Css

Posted by Weston Ganger

If you want to make a square in css, you can do the following.


<div class="square">
  <div class="innerContainer">

The CSS:

  position: relative;
  position: absolute;

The width and padding-bottom must be equal and provide the square and do not have to be in % it can be in pixels or whatever, but the padding-bottom makes for height equal to width.

The absolute position on innerContainer is what makes it so you can add text or stuff inside the square without making the square taller or bigger.

Article Topic:Software Development - HTML / CSS

Date:July 08, 2014

Recommended Posts



Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected