请问我是对块状元素的父元素设置了text-align:center,为何也可以实现块状元素的内容居中
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定宽块状元素水平居中</title>
<style>
div{
border:1px solid red;
}
.nav{
text-align:center;
}
</style>
</head>
<body>
<div class="nav">
<p>我是定宽块状元素,我要水平居中显示。</p>
</div>
</body>
</html>