You're viewing old version number 1. - Current version

Using CSS to center text vertically and horizontally

<html>
<head>
<style>
.divContainer {
display: table;
width: 100%;
height: 100%;
}
.divCenteredObject {
display: table-cell;
vertical-align: middle;
text-align: center;
}
</style>
</head>
<body>
<div class="divContainer">
<div class="divCenteredObject">
<h1>This text is centered, both vertically and horizontally.</h1>
</div>
</div>
</body>
</html>

#css - #howto

From JR's : articles
44 words - 339 chars
created on - #
source - versions

Related articles
Centering multiple div blocks in a responsive manner - Mar 12, 2015
Using CSS to center text vertically and horizontally - Aug 12, 2014



A     A     A     A     A

© 2013-2017 JotHut - Online notebook

current date: May 4, 2024 - 4:04 p.m. EDT