I am completely new to HTML and CSS. I am currently attempting to center two form buttons on a page. Below you'll find the code snippet that I have been working with:
* {
font-family: arial, sans-serif;
}
body {
display: flex;
align-items: column;
}
.buttons {
background-color: #f8f9fa;
border: 1px solid #f8f9fa;
border-radius: 4px;
font-size: 14px;
margin: 11px 4px;
padding: 0 16px;
line-height: 27px;
height: 36px;
min-width: 54px;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
}
.search_area {
display: flex;
color: rgba(0, 0, 0, .87);
border: 1px solid #ddd;
width: 100%;
height: 34px;
font-size: 16px;
border-radius: 25px;
}
nav {
display: flex;
margin-right: 30px;
margin-top: 15px;
}
.search_box {
text-align: center;
display: block;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Google</title>
<link rel="stylesheet" href="google.css">
</head>
<body>
<nav>
<a href="images.html">Image Search</a>
<a href="advanced.html">Advanced Search</a>
</nav>
<form class="search" action="https://www.google.com/search">
<img id="logo" src="logo.png" alt="Google logo">
<div>
<input name="q" type="text" class="search_area">
</div>
<input type="submit" value="Search Google" class="buttons">
<input type="submit" value="I'm Feeling Lucky" class="buttons">
</form>
</body>
</html>
Upon inspection, it is evident that the two buttons positioned below the search bar are aligned to the left. Despite applying text-align: center
, the buttons do not seem to be centralized as expected.
Any suggestions on how I could successfully center these two buttons on the screen?
Thank you in advance!