Skip to content

ThirteeNov

My personal blog about coding and internet

Menu
  • About me
  • About Zofia Kreasi
  • Cart
  • Checkout
  • Making an airplane game from scratch in Unity
  • My account
  • Privacy Policy
  • Privacy Policy – zkLeaderboard
  • Sample Page
  • Shop
  • Tutorials on Learning JavaScript
  • ZKAccounts – Privacy Policy
Menu

How to add a text at the center of HTML page

Posted on November 12, 2020January 15, 2021 by Habibie

So many times I need to make an element, for example an image element, that appears exactly at the center of an HTML page.

I did it, and here I share the code:

<!DOCTYPE html>
    <html>
        <head>
            
            <title>I am on the center</title>
            <meta charset="utf-8">
            <meta http-equiv="Pragma" content="no-cache" />
            <meta http-equiv="Expires" content="0" />
            <meta http-equiv="x-ua-compatible" content="ie=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
            
            <style>
                body, html{
                    height: 100%;
                    padding: 0px;
                    margin: 0px;
                }
            </style>
        </head>
        <body style="display: table; width: 100%;">
            <div style="display: table-row;">
                <div style="text-align: center; display: table-cell; vertical-align: middle;">
                    <p>I am on the center</p>
                </div>
            </div>
        </body>
    </head>
</html>
Post Views: 327
ciihuy2020

Welcome!

  • My YouTube Channel
  • My GitHub Page
  • About me

Categories

  • 3DVista
  • Android
  • Apache
  • C#
  • Cordova
  • Electron & Node JS
  • HTML5, CSS & JavaScript
  • iOS
  • Let's Make Unity Games
  • Misc
  • Photoshop
  • PHP
  • Python
  • Uncategorized
  • Unity
  • WordPress

Recent Posts

  • Hover Reveal script for Unity to show and hide object on mouse hover
  • How to Prevent UI Clicks in Unity from “Bleeding Through” to 3D Objects Behind Them
  • Make objects like wires and cables easily in Unity using Ciihuy Curved Mesh
  • [SOLVED] Can’t Add Custom Domain to Blogger After Losing CNAME Verification
  • iOS App Icon Generator by CiihuyCom
© 2026 ThirteeNov | Powered by Superbs Personal Blog theme