Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Can’t get h1 element to display on the same line as navigation links

Imf94

Coder
Hi!


"Old" Newbie here. I have not been coding css or html in about 10 years now. Use to be good at it and really like doing it as well. So now during covid and lockdown I decided to get back at it again. Currently just re-learning everything, and trying to build up a website from scratch.

Having some issues with getting menu/navigation links in position on the same line as my h1 title. Have tried about everything, like ex. display: inline-block; and also read a lot of posts here. But nothing seems to be working. So I hope somebody here that have any suggestions?

Thank you so much!
 
Can you post the code with BBCode (</>)
HTML:
  <h1>NAME</h1>
    <nav>
        <ul class="menu">
            <li><a href="index.html">work</a></li>
            <li><a href="motion.html">motion</a></li>
            <li><a href="info.html">info</a></li>
            <li><a href="contact.html">contact</a></li>
        </ul>


        
    </nav>


CSS:
/* MENU */
 

ul {
    float: right;
    display: inline;

}
a:hover, a:visited, a:link, a:active
{
    text-decoration: none;
    color: black;
    display: inline-block;
}

.menu a:hover {
    color: grey;
}


.menu li{
    color: rgb(0, 0, 0);
    font-size: 13px;
    font-weight: bold;
    font-style: italic;
    background-color: rgb(255, 255, 255);
    list-style:none;
    margin: 20px;
    display: inline;
    float:right;


}

.menu li a {
    display: inline-block;
    text-decoration: none;
    color:black;
}
 
HTML:
    <nav>
        <ul class="menu">
            <h1>NAME</h1>
            <li><a href="index.html">work</a></li>
            <li><a href="motion.html">motion</a></li>
            <li><a href="info.html">info</a></li>
            <li><a href="contact.html">contact</a></li>
        </ul>


        
    </nav>
Wouldn't it be that?
 
HTML:
    <nav>
        <ul class="menu">
            <h1>NAME</h1>
            <li><a href="index.html">work</a></li>
            <li><a href="motion.html">motion</a></li>
            <li><a href="info.html">info</a></li>
            <li><a href="contact.html">contact</a></li>
        </ul>


       
    </nav>
Wouldn't it be that?
Yes, I've tried that. And it works, but I want the h1 title to be on the left side, and the menu on the right. Like the image attached, just on the same line. Do you have any suggestions on how to do that?
 

Attachments

  • Skjermbilde 2021-03-07 kl. 17.03.33.png
    Skjermbilde 2021-03-07 kl. 17.03.33.png
    19.6 KB · Views: 5
Yes, I've tried that. And it works, but I want the h1 title to be on the left side, and the menu on the right. Like the image attached, just on the same line. Do you have any suggestions on how to do that?
HTML:
 <!DOCTYPE HTML>
 <link rel="stylesheet" href="style.css" type="text/css"
 <h1>NAME</h1>
    <nav>
        <ul class="menu">
            <li><a href="index.html">work</a></li>
            <li><a href="motion.html">motion</a></li>
            <li><a href="info.html">info</a></li>
            <li><a href="contact.html">contact</a></li>
        </ul>


        
    </nav>
You forget to link the css.
 
HTML:
 <!DOCTYPE HTML>
<link rel="stylesheet" href="style.css" type="text/css"
<h1>NAME</h1>
    <nav>
        <ul class="menu">
            <li><a href="index.html">work</a></li>
            <li><a href="motion.html">motion</a></li>
            <li><a href="info.html">info</a></li>
            <li><a href="contact.html">contact</a></li>
        </ul>


       
    </nav>
You forget to link the css.
No, I've linked the css. I just did not include dit in the code I sent. Sorry about that
 
Back
Top Bottom