What would be the proper way to do this? I have an <h1>
tag, and I want to display a <a>
that is inline with it.
views:
142answers:
5
+5
A:
display: inline
should do the trick. It will make the <h1>
behave like any inline element.
Pekka
2010-02-10 20:50:16
A:
Or you could float it to the left (or right):
float: left;
However, this can cause other problems sometimes.
adamse
2010-02-10 20:52:06
A:
Also, margin-top: - height-of-h1
on a
could do the trick - you have like 1000 options (almost literally), we can't tell you more until we see some sample code.
Adam Kiss
2010-02-10 20:58:32
+1
A:
By default the h1 tag has a display:block; Thus changing it to display:inline you will lose the normal feel of an h1. But your link will directly follow it.
Also why not just place the link within the h1 tag? ie:
<h1>Hello <a href="http://www.example.com"> World</a></h1>
corymathews
2010-02-10 21:01:55
The h1 tag is a structural tag. It tells the browser something about the structure of the document. The anchor might not be part of this structural element: it can be a link to the edit page of a blog article or wiki part. You might just want to show it inline with the header, although it is part of the underlying content.
Scharrels
2010-02-10 21:05:10
A:
Or you could use a tag:
<h1>Important title <span style="float:right"><a href="#">Link</a></span></h1>
vectran
2010-02-10 21:05:14