8

I have a couple of links that have a margin-left of 3px. These links are underlined and look like that:

<a href='#'>
    test
</a>

Unfortunately, there are spaces inside the link and I'm not able to remove these space since I don't have access to the HTML code. These spaces are also underlined, which I'm not happy with. Is there any way to remove them without changing the HTML?

Here is a fiddle that shows my problem: http://jsfiddle.net/e8quz/

Update:
Here is a picture, what I want it to look like: enter image description here

2
  • 1
    dont think you can do that without removing the actual spaces or editing the html in other way. Commented Apr 20, 2014 at 13:18
  • So you'd like to "hide" the original HTML and display a different HTML with your specific formatting...is that right? How are you accessing the original HTML? Commented Apr 20, 2014 at 13:25

3 Answers 3

7

The spaces come from the line-breaks (well-known from the display:inline-block problematic).

So make your a elements display: block and float them to the left.

DEMO

PS: The display:block is "redundant", as float normally already sets the display property of the respective element to "block". But it do no harm ...!

Sign up to request clarification or add additional context in comments.

6 Comments

just setting display:inline-block works great. Using float sometimes is not suitable.
@KingKing Yes, like always in web design - it depends! But be aware, that it gives not the same result. Using display:inline-block gives you still an additional space (depending on the respective markup).
could you please make some fiddle showing that display:inline-block will fail? because for the OP's HTML code, it works.
Here is the case showing that using float is not really suitable jsfiddle.net/viphalongpro/e8quz/3 , while if using display:inline-block we have the expected result jsfiddle.net/viphalongpro/e8quz/4
@KingKing No, you got me wrong. It does not "fail". It just gives you a (slightly) different result, as the line-breaks will cause some "extra space". That's all I meant. ;-)
|
2

See here: http://jsfiddle.net/BWc2U/2/

This will also solve the issue. There is no need to make them floats, with the floats you need to clear the floats otherwise all content after will also be floated etc...

a {
  margin-left: 5px;
  display: inline-block;
}

1 Comment

I'm aware of that and I pointed it out at my question: "there are spaces inside the link ". The problem is: I can't change the HTML as you did. I just have access to the CSS files.
1

You can just float the links to make the white space disappear without editing the html

a {
    margin-left: 5px;
    float: left;
}

http://jsfiddle.net/e8quz/2/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.