Select Categories Below
Advertisement
Start Your Own Q&A Site
Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.
Status: Closed Points: 75 Time: 03:42 - Mar 07, 2007
sbjc23
I've tried a number of things but none of them seem to be working effectively.
Categories:
Add Categories
When adding more than one category, separate them with commas.
jgivoni
Date:: Mar 07, 2007
Time:: 08:20
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
Date:: Mar 12, 2007
Time:: 18:40
Thanks Jakob
Question Answered
This question has been closed, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.
Answer 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:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Date:: Jan 06, 2009
Time:: 02:40
The answer depends on whether your link is part of a text paragraph or living by itself. First some background: A normal hyperlink in HTML is created with the <a> tag. <a> tags are per default 'inline' elements, and as such should always appear inside a 'block' level element, usually <p>. Inline elements cannot have top or bottom margins: http://www.w3.org/TR/CSS21/box.html#marg... (quote) "[...] vertical margins will not have any effect on non-replaced inline elements." Setting vertical margins on these elements will simply be ignored. (A 'replaced inline element', in case you were wondering, is for instance an inline image, which CAN have vertical margins.) You can set horizontal (left and right) margins, though: a.myLink { margin-left: 10px; } If your link is not part of a paragraph, you can consider turning it into a block level element and then you will be free to give it margins as you wish: a.myLink { display: block; margin: 5px 10px; } Best regards, Jakob
Click here to see the Answer Discussion that preceded this tutorial.
Login to rate this tutorial: Good | Bad
tecbrat
Date:: Aug 17, 2011
Time:: 10:32
I know this is an old thread, but it might stil be helpful. Try line-height for vertical space on links. a.myLink { line-height:200%; }
Questions
How do I set a hyperlink reference's (link's) margin in CSS?
How do I set the margin for a Cell in CSS?
You have 100 characters to use
Rank
Expert
Points
1.
10279
2.
6493
3.
5596
4.
4848
5.
3487
6.
2840
7.
2770
8.
2303
9.
1820
10.
917
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software