Source Code: (back to article)
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
div {
border: 3px solid lightblue;
height: 80px;
padding-top: 10px;
}
p {
margin: 0 auto 30px;
border: 1px solid lightgreen;
width: 250px;
}
span {
display: block;
margin: 0 auto;
border: 1px solid green;
max-width: 200px;
}
</style>
</head>
<body>
<h1>Horizontally aligned elements</h1>
<div>
<p>A horizontally aligned text.</p>
<span>A horizontally aligned text.</span>
</div>
</body>
</html>