Skip to content

Instantly share code, notes, and snippets.

@pethaniakshay
Last active May 28, 2017 07:43
Show Gist options
  • Save pethaniakshay/1a8197dfe10e6217ff832a29d3aa813c to your computer and use it in GitHub Desktop.
Save pethaniakshay/1a8197dfe10e6217ff832a29d3aa813c to your computer and use it in GitHub Desktop.
HTML/CSS code to vertically+horizontally centre the text in div tag. https://www.codepuran.com/web-designing/vertically-horizontally-align-text-div/
<!DOCTYPE html>
<html lang="de">
<head>
<title>Verticlly Center Text</title>
<style>
.centre-text {
display: table;
height: 100px;
width: 100%;
text-align: center;
border: 2px dashed #f69c55;
}
.text {
display: table-cell;
vertical-align: middle;
}
</style>
</head>
<body style="background:#3cedd5">
<div class="centre-text">
<span class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment