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

只愿长相守 提交于 2020-04-10 05:16:35

问题


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?


回答1:


Simply add:

h2{
    display: inline;
}

To your CSS and the problem will be solved.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/19917922/how-do-i-put-multiple-links-on-the-same-line-html5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!