Register  |  Login

Question Details    

   Question

Time: 03:42 - Mar 07, 2007     Asked by: sbjc23      Status: Answered      Points: 75   

How do I put a margin around a link in CSS?

I've tried a number of things but none of them seem to be working effectively.

Ask a New Question

Become a Quomon Expert

Current Categories

 

Other Questions Needing Answers


   

Answer Discussion
Answer Discussion
Answer Summaries
Answer Summary
 
The short answer is that you cannot put a top or bottom margin on an inline element.
The <a> tag is an inline element, and should appear inside a block element like <p>.

The correct solution would have been to cast the <a> element as an inline-block:
[In CSS]
a.withMargin
{
display: inline-block;
margin: 50px 10px;
}

But the "inline-block" unfortunately is not supported by all browsers. For me, Firefox 2 didn't respond to it.

Instead I believe you should put the margin on the containing block element.
I don't know if there is a better solution in your specific case, but if you post some of your code and explains how it should look, we might find out.

For instance - if your link is not inside a <p> tag and really is not part of a line of text, you can just put "display: block" on it and it will behave like a normal block element and have whatever margins you set.

Jakob

Expert:

jgivoni

Date:

Mar 07, 2007

Time:

08:20

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Thanks Jakob

Expert:

sbjc23

Date:

Mar 12, 2007

Time:

18:40

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Question Answered

This question has been answered, and points have been rewarded to the following experts:

jgivoni: 75

You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.

 
No summaries have been submitted yet. Want to be the first?



Respond to this question:

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

 

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

   

"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it


All Questions


Language Options

English:

www.quomon.com

Español:

www.quomon.es

Quomon Blog

blog.quomon.com

Sponsors

Questions and Answers Software
Real Estate Postcards
Marketing Fulfillment