# How to Center a Div Vertically and Horizontally Using Only CSS? 

**URL:** <https://forums.unrealengine.com/t/how-to-center-a-div-vertically-and-horizontally-using-only-css/2656337>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [September 13, 2025, 1:22pm UTC](https://forums.unrealengine.com/t/how-to-center-a-div-vertically-and-horizontally-using-only-css/2656337 "2025-09-13T13:22:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![auroraxfnafna](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@auroraxfnafna](https://forums.unrealengine.com/u/auroraxfnafna)\
**Post date:** [September 13, 2025, 1:22pm UTC](https://forums.unrealengine.com/t/how-to-center-a-div-vertically-and-horizontally-using-only-css/2656337/1 "2025-09-13T13:22:35Z")

</div>

Hi everyone,

I’m trying to center a `<div>` both **vertically and horizontally** in the browser window using **only CSS** , without relying on flexbox or grid. I’ve seen a few different methods online, but I’m not sure which one is the most reliable or widely supported.

Here’s a simplified version of my HTML:

```auto
<div class="container">
  <div class="box">Centered Box</div>
</div>

```

What would be the best CSS approach to center `.box` inside `.container` both ways, especially if I want it to work across most browsers, including older ones?

I’m also open to flexbox or grid solutions if that’s the recommended modern way, but I’d love to understand the differences.

Thanks in advance!
