tags:

views:

142

answers:

5

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.

+5  A: 

display: inline

should do the trick. It will make the <h1> behave like any inline element.

Pekka
A: 

Or you could float it to the left (or right):

float: left;

However, this can cause other problems sometimes.

adamse
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
+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"&gt; World</a></h1>
corymathews
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
A: 

Or you could use a tag:

<h1>Important title <span style="float:right"><a href="#">Link</a></span></h1>
vectran