
July 20th, 2005, 11:38 PM
| | | CSS Syntax for element "X" followed by element "Y" ?
I'm trying to limit the space between an <h1> and an <h2>, which
immediately follows. Isn't there some syntax for this?
<h1>Main Header</h1>
<h2>Sub Header</h2>
There's too much space between the two by default, but I only want to
modify the relative proximity when <h1/> is followed by <h2/>.
This is possible, isn't it?
Thanks,
Jamie | 
July 20th, 2005, 11:38 PM
| | | Re: CSS Syntax for element "X" followed by element "Y" ?
On Wed, 19 May 2004 11:06:48 -0400, Jamie Jackson
<mcsqueebagePleaseDontSpamMe@hotmail.com> wrote:
[color=blue]
> I'm trying to limit the space between an <h1> and an <h2>, which
> immediately follows. Isn't there some syntax for this?
>
> <h1>Main Header</h1>
> <h2>Sub Header</h2>
>
> There's too much space between the two by default, but I only want to
> modify the relative proximity when <h1/> is followed by <h2/>.
>
> This is possible, isn't it?
>
> Thanks,
> Jamie[/color]
There is CSS for this, but support is weak. I suggest classing such h1's
and setting margin-bottom: 0 to them, which leaves the h2 margin only,
which I suspect is desired. | 
July 20th, 2005, 11:38 PM
| | | Re: CSS Syntax for element "X" followed by element "Y" ?
"Jamie Jackson" <mcsqueebagePleaseDontSpamMe@hotmail.com> wrote in message
news:9ntma05o6r5tn736nt4hushgnaaki1acpr@4ax.com...[color=blue]
> I'm trying to limit the space between an <h1> and an <h2>, which
> immediately follows. Isn't there some syntax for this?
>
> <h1>Main Header</h1>
> <h2>Sub Header</h2>
>
> There's too much space between the two by default, but I only want to
> modify the relative proximity when <h1/> is followed by <h2/>.
>
> This is possible, isn't it?[/color]
Yes and no. The actual margin between vertically adjacent blocks is the
greater of the top block's bottom margin and the bottom block's top margin.
You can use
h1 + h2 { margin-top: ??; }
to set the top margin for the H2 element, but there isn't any way to select
an H1 that immediately precedes an H2. (If ALL your H1's are directly
followed by an H2, then you can just set margin-bottom for all H1's.) | 
July 20th, 2005, 11:38 PM
| | | Re: CSS Syntax for element "X" followed by element "Y" ?
"Harlan Messinger" <h.messinger@comcast.net> wrote in message
news:2h1c5mF7sg5eU1@uni-berlin.de...[color=blue]
>
> "Jamie Jackson" <mcsqueebagePleaseDontSpamMe@hotmail.com> wrote in message
> news:9ntma05o6r5tn736nt4hushgnaaki1acpr@4ax.com...[color=green]
> > I'm trying to limit the space between an <h1> and an <h2>, which
> > immediately follows. Isn't there some syntax for this?
> >
> > <h1>Main Header</h1>
> > <h2>Sub Header</h2>
> >
> > There's too much space between the two by default, but I only want to
> > modify the relative proximity when <h1/> is followed by <h2/>.
> >
> > This is possible, isn't it?[/color]
>
> Yes and no. The actual margin between vertically adjacent blocks is the
> greater of the top block's bottom margin and the bottom block's top[/color]
margin.[color=blue]
> You can use
>
> h1 + h2 { margin-top: ??; }
>
> to set the top margin for the H2 element, but there isn't any way to[/color]
select[color=blue]
> an H1 that immediately precedes an H2. (If ALL your H1's are directly
> followed by an H2, then you can just set margin-bottom for all H1's.)[/color]
Oh, and IE won't recognize the h1 + h2 syntax anyway. | 
July 20th, 2005, 11:38 PM
| | | Re: CSS Syntax for element "X" followed by element "Y" ?
On Wed, 19 May 2004 11:33:47 -0400, "Harlan Messinger"
<h.messinger@comcast.net> wrote:
[color=blue]
>
>"Harlan Messinger" <h.messinger@comcast.net> wrote in message
>news:2h1c5mF7sg5eU1@uni-berlin.de...[color=green]
>>
>> "Jamie Jackson" <mcsqueebagePleaseDontSpamMe@hotmail.com> wrote in message
>> news:9ntma05o6r5tn736nt4hushgnaaki1acpr@4ax.com...[color=darkred]
>> > I'm trying to limit the space between an <h1> and an <h2>, which
>> > immediately follows. Isn't there some syntax for this?
>> >
>> > <h1>Main Header</h1>
>> > <h2>Sub Header</h2>
>> >
>> > There's too much space between the two by default, but I only want to
>> > modify the relative proximity when <h1/> is followed by <h2/>.
>> >
>> > This is possible, isn't it?[/color]
>>
>> Yes and no. The actual margin between vertically adjacent blocks is the
>> greater of the top block's bottom margin and the bottom block's top[/color]
>margin.[color=green]
>> You can use
>>
>> h1 + h2 { margin-top: ??; }
>>
>> to set the top margin for the H2 element, but there isn't any way to[/color]
>select[color=green]
>> an H1 that immediately precedes an H2. (If ALL your H1's are directly
>> followed by an H2, then you can just set margin-bottom for all H1's.)[/color]
>
>Oh, and IE won't recognize the h1 + h2 syntax anyway.[/color]
Okay guys, thanks for the solutions. I'll play with them.
Jamie |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|