I managed to center text inside a table cell using display: table-cell, vertical-align: middle, and text-align: center. However, I'm experiencing unwanted spacing above and below the text. How can I completely eliminate it? I want zero margin/padding all around the text.
PS- I've attempted to use border-collapse: collapse
but it doesn't seem to be working as intended.
(You can also view the fiddle linked below...)
HTML:
<body>
<div>
<h1><a href=#>H</a></h1>
<h1><a href=#>E</a></h1>
<h1><a href=#>L</a></h1>
<h1><a href=#>L</a></h1>
<h1><a href=#>O</a></h1>
</div>
</body>
CSS:
body {
font-family: 'Sigmar One', cursive;
font-size: 100px;
color: white;
text-shadow: 4px 4px 4px #000;
background-color: blue;
width: 100%;
height: 100%;
margin: 0;
}
div {
position: absolute;
height: 100%;
width: 100%;
display: table;
}
h1 {
display: table-cell;
vertical-align: middle;
text-align: center;
}
a:visited, a:active {
text-decoration: none;
color: white;
}
a:link {
text-decoration: none;
color: white;
text-shadow: 0px 2px 3px rgba(255,255,255,.25);
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
}
a:hover {
text-shadow: 4px 4px 4px #000;
color: white;
}