---
title: "Discussion on \"3 Easy Ways to Center a Div/Element\" | Hashnode"
description: "Discussion on \"3 Easy Ways to Center a Div/Element\". The primary issue faced by most Developers these days is irregular div alignment. Keeping everything aligned is important for developers to make their websites more appealing to the audience. In this blog, I’ll be telling you about 3 easy ways that c..."
url: "https://hashnode.com/posts/3-easy-ways-to-center-a-divelement/63e4ffc4553cad5af67ece59"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [3 Easy Ways to Center a Div/Element](https://kajal1801.hashnode.dev/3-easy-ways-to-center-a-divelement?utm_source=hashnode&utm_medium=feed)

The primary issue faced by most Developers these days is irregular div alignment. Keeping everything aligned is important for developers to make their websites more appealing to the audience. In this blog, I’ll be telling you about 3 easy ways that c...

Feb 9, 2023 · 3 min read · kajal1801.hashnode.dev  
Read the article

-   [#css](https://hashnode.com/tag/css)
-   [#technical-writing-1](https://hashnode.com/tag/technical-writing-1)
-   [#center-a-div](https://hashnode.com/tag/center-a-div)

## Written by

[Kajal Jaiswal](https://hashnode.com/@kajal1801)

@kajal1801 · West Bengal, India

  
[View profile](https://hashnode.com/@kajal1801)

SDE @Amazon

I'm a problem solver, community manager, and an SDE @Amazon. I believe in learning and growing with the community and giving back to the community.

## Responses 4

Markdown supported · ⌘↵ to post

[Srikar Mk](https://hashnode.com/@SrikarMK)

[Feb 15, 2023](https://hashnode.com/posts/3-easy-ways-to-center-a-divelement/63e4ffc4553cad5af67ece59/comment/63ece4277cedde50200b7c16)

Pretty nice. Congrats on finally posting your first blog 🫡.

[Andrew Savetchuk](https://hashnode.com/@AndrewSavetchuk)

[Feb 9, 2023](https://hashnode.com/posts/3-easy-ways-to-center-a-divelement/63e4ffc4553cad5af67ece59/comment/63e5749fdb59c3f72b9f314f)

Good article! It is also possible to center the div using CSS grid like so:

```
body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  display: grid;
  justify-content: center;
  align-items: center;
}

div {
  background: lightgreen;
  height: auto;
}
```

[Kajal Jaiswal](https://hashnode.com/@kajal1801)

[Feb 10, 2023](https://hashnode.com/posts/3-easy-ways-to-center-a-divelement/63e4ffc4553cad5af67ece59/comment/63e5749fdb59c3f72b9f314f#reply-63e5b218f30581f89abccfcb)

Hey thanks for your input.. I actually didn't add grids because I feel it's a really great topic and I should write another blog specifically for grids. In this blog i only mentioned 3 easy ways to center elements, i know there are many more but these are like easiest tricks.

[Royalty](https://hashnode.com/@Royalty)

[Feb 9, 2023](https://hashnode.com/posts/3-easy-ways-to-center-a-divelement/63e4ffc4553cad5af67ece59/comment/63e5239cf30581f89abcc4e4)

Awesome article.

[Prantik Kumar Seal](https://hashnode.com/@prantikseal)

[Feb 9, 2023](https://hashnode.com/posts/3-easy-ways-to-center-a-divelement/63e4ffc4553cad5af67ece59/comment/63e50ef2f30581f89abcc1fb)

Awesome blog kajal!

[Kajal Jaiswal](https://hashnode.com/@kajal1801)

[Feb 9, 2023](https://hashnode.com/posts/3-easy-ways-to-center-a-divelement/63e4ffc4553cad5af67ece59/comment/63e50ef2f30581f89abcc1fb#reply-63e51149db59c3f72b9f2610)

Thanks
