473,394 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Indenting headings and adjacent siblings?

I have a complex document that goes several heading levels deep, and
it's unreadable with all the headings and paragraphs against the left
margin. I'd like to indent H2 elements by 50 pixels, H3 elements by
100 pixels, and so on. The tricky part is that I need to get the
paragraphs following each heading as well.

Grouping everything in a DIV isn't an option for me, because I'm not
the one generating the HTML (It's being done by a POD to HTML
converter: http://search.cpan.org/dist/Pod-HtmlEasy/).

Here's the "solution" I came up with using adjacent selectors:

.pod H2,
.pod H2 + *,
.pod H2 + * + *,
[snip]
.pod H2 + * + * + * + * + * + * + * + * + *,
.pod H2 + * + * + * + * + * + * + * + * + * + * { margin-left: 50px;
}
.pod H3,
.pod H3 + *,
.pod H3 + * + *,
[snip]
.pod H3 + * + * + * + * + * + * + * + * + *,
.pod H3 + * + * + * + * + * + * + * + * + * + * { margin-left: 100px;
}
[etc...]

Now, this works, but, a few problems come to mind immediately:
-The CSS is butt-ugly.
-It boosts the size of my resulting document considerably.
-Any more than 10 paragraphs under one heading, and the 11th will drop
back to the left margin.

Is there a better way to do this, ideally not involving an enclosing
element (which will be hard for me to generate)? Any help is most
appreciated!

Nov 23 '05 #1
2 1745
sg********@hotmail.com wrote:
Grouping everything in a DIV isn't an option for me, because I'm not
the one generating the HTML (It's being done by a POD to HTML
converter: http://search.cpan.org/dist/Pod-HtmlEasy/).


Change the Perl script so that it wraps groups in a div.

--
Spartanicus
Nov 24 '05 #2
OK, I guess that's the "right" way to do it, and I was able to without
modifying the original source. Here's what I did, for reference by
Perl/Pod::HtmlEasy users:

#Create the Pod::HtmlEasy object...
my $podhtml = Pod::HtmlEasy->new(
#[snip]
#Revise the handler for =head2.
on_head2 => sub {
my ($this, $txt, $a_name) = @_;
my $html = '';
my $level = 2;
$html .= "</div>\n\n\n" if $this->{HEADING_LEVEL};
$html .= "<div class='h$level'>\n";
$this->{HEADING_LEVEL} = $level;
$html .= "<a name='$a_name'></a><h$level>$txt</h$level>\n\n";
},
#[Similar subroutine reference for on_head3]
);

That wraps the heading and subsequent items in a "<div
class='h2'>...</div>". Then I can do this in my stylesheet:

.h2 { margin-left: 50px; }
.h3 { margin-left: 100px; }
/*etc.*/

Works like a charm, even in IE.

The path I was on lead to madness; so thanks for the guidance.

Nov 28 '05 #3

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

Similar topics

20
by: Jeff Thies | last post by:
I'm working on yet another online editor, this allows non html savy people to add "blocks" that may contain paragraphs, headings, lists and images to the editable part of a template. The editable...
5
by: Chris Reigrut | last post by:
I have a bunch of (old) pages that are outline-driven, and use the h1-h6 elements to define headings. Is there any way that I can create a stylesheet to show them in an indented style? For...
0
by: David Ehmer | last post by:
Appreciate any ideas about what might be happening with these pages in IE5.2 Mac. In summary the 2nd paragraph or list item is indenting to the right. paragraphs of list items after the 2nd...
7
by: Ellen Manning | last post by:
I've got an A2K report showing students and their costs. Student info is in the main report and costs are in a subreport for each student. The user inputs the program desired then only those...
14
by: Dan Jacobson | last post by:
How is this for correct HTML 4.01 headers?: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="zh-tw"><head> <meta http-equiv="Content-Type"...
7
by: Harrie | last post by:
Hi group, I want to indent existing XML files so they are more readable (at least to me). At this moment I'm looking at the XML files OpenOffice.org's Writer application produces in it's zipped...
3
by: sdisalvo | last post by:
I'm looking for a way to filter records in a query (or report) based on a value in a field of an adjacent record. Can this be done easily? I cannot find any info in the help files. Thanks
22
by: Spartanicus | last post by:
I wrote an article on HTML headings: http://codewallop.110mb.com/goodpractice/headingology.htm -- Spartanicus
5
by: Nathan Sokalski | last post by:
I'm not sure if this is the right place to ask this question, but I wasn't sure where else to go. I have a table made of the following tags: <table class="myclass"> <tbody> <tr><td>.</td></tr>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.