How to {Centre Elements}

Alignment is a useful aspect of CSS that allows you to position things such as text or images on a page, generally you will align something to the left, right or centre.

alignment examples

Margin is used to generate space around elements. For instance, if you want to put an image in the centre of a page, margin can be used, an example of how it can be used it shown below.

p {
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
}

When adding value to this property, you’ll need to add both length (for width) & a percentage relative to the space.

Depending on the values you add to the property, whatever it is you’re trying to move’s position will change. You can also set this value to auto, where the browser will calculate the margin by itself, this is often used to centre objects.

p {
 margin: auto;
}
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.