473,801 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 20 '05 #1
4 8673
On Wed, 19 May 2004 11:06:48 -0400, Jamie Jackson
<mc************ *************@h otmail.com> wrote:
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


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.
Jul 20 '05 #2

"Jamie Jackson" <mc************ *************@h otmail.com> wrote in message
news:9n******** *************** *********@4ax.c om...
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?


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.)

Jul 20 '05 #3

"Harlan Messinger" <h.*********@co mcast.net> wrote in message
news:2h******** ****@uni-berlin.de...

"Jamie Jackson" <mc************ *************@h otmail.com> wrote in message
news:9n******** *************** *********@4ax.c om...
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?
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.)


Oh, and IE won't recognize the h1 + h2 syntax anyway.

Jul 20 '05 #4
On Wed, 19 May 2004 11:33:47 -0400, "Harlan Messinger"
<h.*********@co mcast.net> wrote:

"Harlan Messinger" <h.*********@co mcast.net> wrote in message
news:2h******* *****@uni-berlin.de...

"Jamie Jackson" <mc************ *************@h otmail.com> wrote in message
news:9n******** *************** *********@4ax.c om...
> 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?


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.)


Oh, and IE won't recognize the h1 + h2 syntax anyway.


Okay guys, thanks for the solutions. I'll play with them.

Jamie
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
18740
by: Amol | last post by:
Hi, I want to fetch some values from a XML file, using a java program. I want to retrieve value of path tag for e.g<path>some path</path> tag.(Marked with **** in the below XML file Example) ============= My XML File ============
5
12099
by: RodneyDunes | last post by:
My site did validate and now it doesn't. The error I get is the following: document type does not allow element "META" here ....nt-type" content="text/html;charset=iso-8859-1"> Can someone please tell me what I need to change?These are the Meta tags: </head> <meta http-equiv="Content-type" content="text/html;charset=iso-8859-1"> <META http-equiv="PICS-Label" content=(PICS-1.1 "http://www.classify.org/safesurf/" L gen true for
15
5977
by: Barry | last post by:
Hi group, Does anyone know why I get a W3 validator error (click the validation link at the bottom of the page) for http://www.polisource.com/consumer-protection.shtml saying "Line 227, column 3: end tag for element "P" which is not open." It looks open to me, right before the table tag. Maybe that's why the validator is still in beta, but I thought I'd ask.
2
1665
by: DraguVaso | last post by:
Hi, I have a simple question regardign the syntax: do I have to need double quotation marks or single qoutation marks in my XML? For exemple:µ <?xml version="1.0" or <?xml version='1.0'
4
6932
by: Tom Eldridge | last post by:
Hi all I'm getting tons of these errors when running the w3c validator on my template page. Basically it will say for example: element "TITLE" undefined. Do I need to put this into lowercase or uppercase or have I got completely the wrong end of the stick and need to define my doctype to another? Currently I have this:
1
4749
by: tankbattle | last post by:
That is, what's the difference between <complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complexType> and <complexType name="Address" block="restriction">
4
2492
by: chaitu | last post by:
Hi guys, I've written a parallel build program (in Perl) that takes a pre-computed dependency tree of many projects in 2 visual studio .net 2003 solution (.sln) files here at my company, and builds projects at a same level of dependency parallelly. While doing this, sometimes I get "Microsoft Visual Studio experienced some errors and needs to close" pop-up (which was gone after I disabled error-reporting for programs from Control...
10
4040
by: jonathanemil | last post by:
Hello, I am a 1st semester Computer Science student in a Python class. Our current assignment calls for us to read a list from a file, create a 2-dimensional list from the file, and check to see whether or not 2-dim list constitutes a "magic square" (i.e. all the rows, columns and diagonals equal each other when added). We are to create several definitions, and I have had no problem reading from the file, creating the list, and getting the...
0
9698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10516
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10262
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10052
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9101
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2959
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.