Selecting the child of an ID selector

liunx

Guest
Is it legal CSS to select the child of an ID selector? I'm curious because the statement below doesn't seem to work. What am I doing wrong?

#content > p:first {
margin-top: 0px;
padding-top: 0px;
}Is it not first-child?


#content > p:first-child {
margin-top: 0px;
padding-top: 0px;
}


And of course, a browser that properly supports CSS2. I'm unsure if IE supports this.That worked in Firefox, but IE is pretty flaky it seems. IE doesn't seem to recognize the <p> in the address section below the logo, but recognizes the <p> in the content. It doesn't recognize the :first-child either. Below is the link to what I'm working on. Any help would be appreciated.

<!-- m --><a class="postlink" href="http://www.aloofhosting.com/cobalt/trout/index.html">http://www.aloofhosting.com/cobalt/trout/index.html</a><!-- m -->

The dashes around the <div> and <p>'s are just to help me visualize the layout.IE doesn't support the standards, what do you want?Basically, I'm just trying to get the tops of the address and the first paragraph of the content to line up.can't you simply use #content p or, assign the paragraph an id?I don't want it to apply to every paragraph in #content and I wanted to avoid sticking an ID on the paragraph because the layout is used on more than one page with different content.Well, Internet Explorer is an archaic browser. Yet it's still used. I know no workarounds, short of adding an id. Perhaps one of our other members know.Thanks for your help. I appreciate your time. Hopefully, someone will be able to figure this one out. :)instead of an id coudlnt u use a class?

also, ie doesnt support first-child or any other psuedo element. The only ones it supports is hover, link, active, visited and its only supported on anchor tags. I dont believe Ie supports the > either.Originally posted by pawky
ie doesnt support first-child or any other psuedo element.
Well, actually, IE supports the first-line (<!-- m --><a class="postlink" href="http://www.w3.org/TR/REC-CSS2/selector.html#first-line-pseudo">http://www.w3.org/TR/REC-CSS2/selector. ... ine-pseudo</a><!-- m -->) and first-letter (<!-- m --><a class="postlink" href="http://www.w3.org/TR/REC-CSS2/selector.html#first-line-pseudo">http://www.w3.org/TR/REC-CSS2/selector. ... ine-pseudo</a><!-- m -->) pseudo-elements. ;)Originally posted by Paul Jr
Well, actually, IE supports the first-line (<!-- m --><a class="postlink" href="http://www.w3.org/TR/REC-CSS2/selector.html#first-line-pseudo">http://www.w3.org/TR/REC-CSS2/selector. ... ine-pseudo</a><!-- m -->) and first-letter (<!-- m --><a class="postlink" href="http://www.w3.org/TR/REC-CSS2/selector.html#first-line-pseudo">http://www.w3.org/TR/REC-CSS2/selector. ... ine-pseudo</a><!-- m -->) pseudo-elements. ;)

really? u sure? :P i didnt think it did. Ok, maybe IE does support them, lolI'm a bit new to the whole browser compatability arena. Most of what I've done has been ColdFusion optimized for IE. Good information about what is and is not supported by IE.Originally posted by cobalt
I'm a bit new to the whole browser compatability arena. Most of what I've done has been ColdFusion optimized for IE. Good information about what is and is not supported by IE.

Most people will suggest that you build your site for firefox and then work out the bugs for IE. It is a lot easier this way :)A little JavaScript would solve the problem:
onload=function() {
var oFirstP=document.getElementById('content').getElementsByTagName('p')[0];
oFirstP.style.marginTop=0;
oFirstP.style.paddingTop=0;
}
 
Back
Top