How to create Right Aligned Menu Links using HTML and CSS ?
Last Updated :
21 Nov, 2019
Improve

- HTML code to make the structure:
html <!DOCTYPE html> <html> <head> <title> How To Create Right Aligned Menu Links using HTML and CSS ? </title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <!-- Navbar items --> <div id="navlist"> <a href="#">Home</a> <a href="#">Our Products</a> <a href="#">Careers</a> <div class="navlist-right"> <a href="#">About Us</a> <a href="#">Contact Us</a> </div> </div> <!-- logo with tag --> <div class="content"> <h1 style="color:green; padding-top:40px;"> GeeksforGeeks </h1> <b>A Computer Science Portal for Geeks</b> <p> How many times were you frustrated while looking out for a good collection of programming/algorithm/interview questions? What did you expect and what did you get? This portal has been created to provide well written, well thought and well explained solutions for selected questions. </p> </div> </body> </html>
- CSS code of structure:
html <style> /* styling navlist */ #navlist { background-color: #0074D9; position: absolute; width: 100%; } /* styling navlist anchor element */ #navlist a { float:left; display: block; color: #f2f2f2; text-align: center; padding: 12px; text-decoration: none; font-size: 15px; } .navlist-right{ float:right; } /* hover effect of navlist anchor element */ #navlist a:hover { background-color: #ddd; color: black; } </style>
<!DOCTYPE html>
<html>
<head>
<title>
How To Create Right Aligned Menu
Links using HTML and CSS ?
</title>
<meta name="viewport"
content="width=device-width, initial-scale=1">
<style>
/* styling navlist */
#navlist {
background-color: #0074D9;
position: absolute;
width: 100%;
}
/* styling navlist anchor element */
#navlist a {
float:left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 12px;
text-decoration: none;
font-size: 15px;
}
.navlist-right{
float:right;
}
/* hover effect of navlist anchor element */
#navlist a:hover {
background-color: #ddd;
color: black;
}
</style>
</head>
<body>
<!-- Navbar items -->
<div id="navlist">
<a href="#">Home</a>
<a href="#">Our Products</a>
<a href="#">Careers</a>
<div class="navlist-right">
<a href="#">About Us</a>
<a href="#">Contact Us</a>
</div>
</div>
<!-- logo with tag -->
<div class="content">
<h1 style="color:green; padding-top:40px;">
GeeksforGeeks
</h1>
<b>A Computer Science Portal for Geeks</b>
<p>
How many times were you frustrated while
looking out for a good collection of
programming/algorithm/interview questions?
What did you expect and what did you get?
This portal has been created to provide
well written, well thought and well
explained solutions for selected questions.
</p>
</div>
</body>
</html>
