in reply to CGI.pm: Rendering H1 and H2 tags in the same line

CGI.pm, by default, doesn't insert \n anywhere in its output. What you are seeing is not the result of CGI.pm inserting "crlf" into your CGI program's HTML output. You can run the script from the command line and verify that statement yourself.

What you are seeing is the fact that most browsers automatically render "headlines" one per row. In other words, a <h1></h1> pair always (in most browsers) renders on its own line, even if it's only a few characters long, and a subsequent <h2></h2> pair will render on a subsequent line, again, even if it's only a few characters.

This isn't a Perl issue. It's truly an HTML issue. And I mean that not to try to pawn a problem off somewhere else. Seriously, it's not a Perl issue. It's a misunderstanding of how HTML works. You can solve it by using <font size=....></font> tags instead of headline tags in situations where you wish to control font size instead of rendering a headline.


Dave


"If I had my life to live over again, I'd be a plumber." -- Albert Einstein

Replies are listed 'Best First'.
Re: Re: Layout
by liz (Monsignor) on Nov 13, 2003 at 16:50 UTC
    Totally agree.

    However, there is a yucky way to get them on one line:

    <TABLE><TR><TD><H1>Hello</H1></TD><TD><H2>world!</H2></TD></TR></TABLE +>

    Hello

    world!

    I have no idea how you would do this with CGI.pm.

    And yes, I know this isn't XHTML compatible. XHTML compatible HTML shouldn't contain abominations like this ;-)

    I also would recommend against using it this way: there are other, better ways for controlling the size of your text in HTML.

    Liz

Re: Re: Layout
by hardburn (Abbot) on Nov 13, 2003 at 17:08 UTC

    I think setting the CSS attribute white-space: pre-wrap on the two header tags will do it. Not sure, though.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      What's supposed to be the way to do this is display attribute:
      .inline { display: inline } <h1 class='inline'>First</h1><h2 class='inline'> - Second</h2>

      First

      - Second

      Well that's what supposed to work. --
      Clayton
Re: Re: Layout
by Anonymous Monk on Nov 13, 2003 at 16:48 UTC
    thing is here I've only just picked this up today and can make HTML tags work it just keeps croaking on me could you example me something?

    thanks
    alan.