1

I have the following markup:

<div id="footer">
    <a href="/">Home</a> | 
    <a href="/about">About</a> | 
    <a href="/contact">Contact</a>
</div>

With the following styling:

#footer {
    position: relative;
    float: left;
    background: white;
    width: 960px;
    height: 50px;
    border-bottom-left-radius: 50px;
    border-bottom-right-radius: 50px;
    -moz-border-radius-bottomleft: 50px;
    -moz-border-radius-bottomright: 50px;
    box-shadow: 2px 2px 3px #000;
    -moz-box-shadow: 2px 2px 3px #000;
    -webkit-box-shadow: 2px 2px 3px #000;
}
#footer > a {
    padding-top: 10px;
}

Is there any particular reason that the padding isn't applied to all of the child <a> elements of my #footer div?

I'm trying a similar effect without a parent > child selector somewhere else on my page, so I'm assuming it's a problem with my selector.

Browser version: Chrome 11 Beta Mac OS X

3
  • 1
    The first thing you need to put down is browser model and version. Many older versions of IE do not support the immediate-child selector, e.g. Also, you need to specify what you mean by "not working". Commented Apr 18, 2011 at 3:57
  • turn on Chrome's developer tools, point to the <a> tag in question, and check its padding. There can be millions of reasons why it doesn't show up -- for example, has it been overwritten by a higher-priority rule? Commented Apr 18, 2011 at 4:07
  • 2
    maxdesign.com.au/articles/inline --- top padding is generally ignored for elements that are display: inline; Commented Apr 18, 2011 at 4:23

3 Answers 3

2

@boss, <a> is an inline element not a block element. so, vertically margin & padding only working on block element . Then define display:block in your a tag for more information please check this Why do bottom padding and bottom margins not help to add vertical spacing between these links?

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

Comments

1

Would #footer a:first-child do it?

-- Answer from the comments below --

Ahh, they're all inline. To define padding separate from the others they need to be "block" elements, floating next to each other?

Adding

#footer a { display:block; float:left; }

would give you the ability to give the first one padding the other two don't have

7 Comments

I get the right response using the browser you mentioned. It doesn't seem to discriminate between elements using the '>' though. jsbin.com/oqova4/edit
I am using node.js if that makes any difference. Should I post my server and port number?
I really doubt that would be affecting your CSS. If you can get your design working in jsbin or a standalone HTML file, then it could be nodejs - but to start with I couldn't see how that would affect it. "Apple Alt J" into Dev Tools, and check the styling (as Stephen Chung above mentioned) and check the styling on each element
Try this (jsbin.com/acahe6/3) rough version of what my page looks like. By checking the dev tools, I'm getting no padding. Maybe it is being overwritten.
Adding #footer a { display:block; float:left; } would give you the ability to give the first one padding the other two don't have.... But they look fine inline?
|
1

I'm not quite sure why this isn't working, however as a remedy, I recommend wrapping all your links in like a div and giving that a margin-top. Check out the fiddle...

http://jsfiddle.net/Ft7Tr/

I hope this helps.
Hristo

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.