Я пытаюсь центрировать текст на панели навигации, но по какой-то причине код не работает и остается на левой стороне. Как я могу исправить эту ситуацию, я попытался добавить различные типы кода, чтобы увидеть, будет ли ситуация исправлена, но все еще возникают проблемы с центрированием текста на панели навигации
CSS:
.topnav {
background-color: #333;
overflow: hidden;
}
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #4CAF50;
color: white;
}
HTML:
<!DOCTYPE html>
<html>
<head>
<title>My Wesbite </title>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<div class="topnav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
<div>
<h1> this is header 1</h1>
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</body>
</html>