What steps should I take to align my NAV next to each other on the top right of the page?

Can someone help me align my NAV elements next to each other? I am having trouble figuring out how to do it currently.

#menu { 
    display: inline-block;
    position: absolute;
    right:0;
    top: 10%;
}
<ul id="menu">
       <nav>
      <li><a href="Frontpage.html">Home</a></li>
     <li><a href="Services.html">Services</a></li>
      <li><a href="hobbies.html">My Hobbies</a></li>
      <li><a href="movies.html">My favourite movies</a></li>
    </nav>
</ul>

Answer №1

Do you desire such a thing?

body {
  padding:0;
  margin:0;
}

#menu { 
    display:flex;
   justify-content:flex-end;
   position:absolute;
   top:0;
   right:0;
 }

#menu a {
  color:#000;
  text-decoration:none;
  padding:0 20px;
  height:40px;
  line-height:40px;
  font-family:sans-serif;
}

#menu a:hover {
  background:lightgray;
}
<div id="menu">
       
      <a href="Frontpage.html">Home</a>
     <a href="Services.html">Services</a>
      <a href="hobbies.html">My Hobbies</a>
      <a href="movies.html">My favourite movies</a>
     
</div>

Answer №2

To align the items in your navigation menu horizontally, you can add the float: left; property to the li class. It's important to only apply this style within your nav menu. To make the naming more logical, I have renamed the menu class to nav-menu. Additionally, I have removed the dots from the list items by eliminating the list-style-type.

ul#nav-menu { 
  display: inline-block;
  position: absolute;
  list-style-type: none;
  right: 0;
  top: 10%;   
}

ul#nav-menu li {
    float: left;
    margin-right: 4px;
}
<ul id="nav-menu">
       <nav>
      <li><a href="Frontpage.html">Home</a></li>
     <li><a href="Services.html">Services</a></li>
      <li><a href="hobbies.html">My Hobbies</a></li>
      <li><a href="movies.html">My favourite movies</a></li>
      </nav>
</ul>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a p5.js circle on top of an HTML image: A step-by-step guide

Currently, I am integrating an image into my web application using standard JavaScript and HTML. The image represents a basic map, and my objective is to utilize p5.js to draw on it. <div id="map"> <img src="Assets/MENA.jpg" ...

Troubleshooting a Hover Problem in Firefox

Chrome is rendering the following code perfectly fine, but Firefox seems to be having trouble applying the hover effect. HTML <!DOCTYPE html> <html> <head> <link type="text/css" rel="stylesheet" href="stylesheet.css"/> ...

The height of the href is not displaying correctly when the text-decoration is disabled and it is placed next to

In my design, I have a link positioned next to an image with perfect vertical alignment. Everything looks great when the text has the standard text-decoration, centered vertically and all that. However, as soon as I remove the text-decoration, leaving the ...

You are unable to define a module within an NgModule since it is not included in the current Angular compilation

Something strange is happening here as I am encountering an error message stating 'Cannot declare 'FormsModule' in an NgModule as it's not a part of the current compilation' when trying to import 'FormsModule' and 'R ...

Issues with retrieving $_POST values from a select form in PHP

When the button is clicked, I am sending a AJAX request to my PHP page using POST method with the selected data from a SELECT element. However, I am facing an issue where my PHP IF statements are not evaluating as true. It always defaults to the ELSE condi ...

Fixed Position - Make width match the container's dimensions

I've been experimenting with setting a div's position to fixed once a user has scrolled a certain distance. I've run into an issue where the fixed position div's width doesn't match its parent element. How can I ensure that the fix ...

HTML and JavaScript code to desaturate or grayscale image rollovers without the need for additional image duplicates or sprites

Is there a way to achieve grayscale to color image rollover effects without duplicating images or using sprites? I'm looking for an alternative technique that can accomplish this. Any suggestions on how to implement it? ...

Creating time input forms that are responsive can be achieved by leveraging the features of Bootstrap

Currently, I am working on a Laravel project and I am facing an issue with making a form responsive. I have added the following viewport meta tag, but I have not seen any changes. Any suggestions on how to make this form responsive would be greatly appreci ...

Exploring HTML5 Canvas 2D Frameworks with an emphasis on collision detection and physics simulations

I am seeking the optimal strategy for managing objects within the canvas context. My initial project involves the following tasks: Create a ground drawing. Release a circle onto the ground with collision detection and elasticity. Trigger an explosion tha ...

Designing div arrangements

I am trying to create a layout of divs similar to the one shown in the image: https://i.sstatic.net/DLUe8.png The challenge I am facing is that I need to arrange them in a row, with one large div in the center and four smaller divs on the sides. I am plann ...

Experience seamless video playback on both mobile and web browsers with JW Player

I have integrated the JW Player for video playback on both mobile and web browsers. Currently, I have a library of 100 videos with dimensions set at 1280*700 pixels. These videos work well on web browsers and load quickly depending on internet speed. Howe ...

A guide to examining the HTTP response body, including HTML content, using Wireshark

After entering the URL in the address bar of the virtual machine's browser, a request for an HTML document from my host computer was made. The HTML document, which I had personally written, successfully appeared in the virtual machine's browser. ...

Python and Selenium are a powerful combination, but sometimes you may encounter the error message "Element cannot be clicked at point (x,y)

I'm trying to automate the selection of a checkbox on a webpage using Selenium and Python with this line of code: self.driver.find_element_by_id('lg_1166').click() Unfortunately, I'm encountering an error message: Message: Element < ...

Unable to override the Bootstrap theme

Despite trying multiple methods, I've found it challenging to override the CSS of Bootstrap specifically for this paragraph element P.fs-5.text-muted. Interestingly, all other CSS elements are easily modifiable. Here's an example that works: H1. ...

Place the text within the contenteditable body of a frame at the specific caret position

Within my iframe object, there is a contenteditable body. I am trying to paste text or HTML elements at the caret position. However, when I attempted this code snippet, I encountered an error message saying Cannot read property 'createRange' of u ...

What's the best way to integrate Bootstrap into my HTML document?

Hey there, I'm new to the coding world and just started learning. I could use some assistance with including Bootstrap v5.1 in my HTML code. The online course I'm taking is using an older version of Bootstrap, so I'm having trouble finding t ...

What is the best way to access dropdown sub-menu options from a complex multi-level navigation bar

Struggling to figure out how to open my dropdown sub-menu using CSS. Hoping to make it so the user can open it by hovering over the corresponding tag. I attempted to use #lablinksDD to trigger the opening of #ddSbMenu when hovered over #menuDD with #labLin ...

Is storing HTML tags in a database considered beneficial or disadvantageous?

At times, I find myself needing to modify specific data or a portion of it that originates from the database. For instance: If there is a description (stored in the DB) like the following: HTML 4 has undergone adjustments, expansions, and enhancements b ...

What could be causing my navbar to not be responsive on mobile devices?

I'm in need of assistance. When viewing my website in mobile mode, the collapse hamburger menu is hiding too far to the right. This issue is making the site look unresponsive, and I've been unable to find a solution. It seems like the problem sta ...

Issue with non-responsive clicks in scrollable/List view on Android device due to CSS styling

Currently, I am facing an issue with my WebApplication where I have a dynamically generated very Long List using JQuery Mobile. The problem I am encountering is that I am unable to click on any item within this scrollable view. Although I can hear the soun ...