Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I put multiple links on the same line? (HTML5)

Tags:

html

hyperlink

I'm trying to put multiple links on the same line so I can have a whole bar of links, I've tried this:

<a href="website_homepage.htm"><h2 style="font-family:tempus sans itc;">Home</h2></a> <a     href="website_hills.htm"><h2 style="font-family:tempus sans itc;">Hills Pupil Tailored Website</h2></a>

but when I test to see if it works, these two links are on seperate lines, does anyone know how I can get them on the same line?

like image 309
Matthew W. Avatar asked Nov 11 '13 23:11

Matthew W.


People also ask

How do I put links side by side in HTML?

Give your links a display of "inline-block" and they will appear next to each other. You can then add some padding or margin to give them some space. You can achieve the same result by using the li tag and giving them the display:inline-block style.

How do you add 3 links in HTML?

The <a> tag defines a hyperlink and is used to link from one page to another. href attribute is used with the <a> tag, which indicates the link's destination. To create page links in an HTML page, we need to use the href attribute of the <a> and </a> tag. Make sure that the <a></a> tag is placed with in the <body>…

How do you create links to sections within the same page in HTML?

Use the #id selector from another page You can also jump to a specific part of another web page by adding #selector to the page's URL.

Can you have multiple link tags in HTML?

A HTML document can have multiple <link> elements to load different script or page types. All of these <link> elements must be placed in the <head> section of the HTML document.


3 Answers

Simply add:

h2{
    display: inline;
}

To your CSS and the problem will be solved.

like image 169
Joshua Avatar answered Sep 21 '22 06:09

Joshua


That's because of h2 display property which is block.

Try with:

h2 {
    display: inline-block;
}

or

h2 {
    display: inline;
}

at the beginning of your file (enclosed by <style> tags) or in your stylesheet file.

See Typical default display properties here

like image 25
Jerska Avatar answered Sep 20 '22 06:09

Jerska


Alternatively replace "h2" with for example "span" and the links will be on the same line.

or you could put:

<h2 style="font-family:tempus sans itc;"><a href="website_homepage.htm">Home</a> <a href="website_hills.htm">Hills Pupil Tailored Website</a></h2>

Putting all the links within one h2 tag instead of using one for each link.

like image 38
user2757572 Avatar answered Sep 19 '22 06:09

user2757572