Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Am I missing something? I'm not seeing anything in the CGI docs regarding font size/color, etc.

Much Obliged.

Replies are listed 'Best First'.
(Ovid - CSS in external file) Re: CGI
by Ovid (Cardinal) on Dec 22, 2000 at 03:17 UTC
    Also, if you have your CSS in a separate file, you can use the following:
    print $q->start_html( -title => "Some Title Here", -style => { src => '../style.css', type => 'text/css' } );

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: CGI
by PsychoSpunk (Hermit) on Dec 22, 2000 at 02:49 UTC
    Try

    print $cgi->p([font(color=>"red", size=>"+2")], "This is my text");

    CGI supposedly can handle tags that aren't explicitly handled. You'll need to double check my CGI statement for valid syntax, but I think that's how it goes.

    ALL HAIL BRAK!!!

Re: CGI
by damian1301 (Curate) on Dec 22, 2000 at 04:00 UTC
    See, the greatest thing about CGI.pm is the ability to define your own HTML tags using it. Example:
    use CGI qw/shortcuts font/; $q = new CGI; print $q->font ({size=>'1',color=>'red'}, $q->p("Heyyy"));
    But the problem is, why would you want to do this? Why not just print <font size=1 color=red><p>Heyyy</p>? Sorry if I sounded harsh, no hurt intended :-)

    Wanna be perl hacker.
    Dave AKA damian
      ...why would you want to do this? Why not just print <font size=1 ...
      Stylesheets are here to stay and they are a Good Thing. Font tags are deprecated. HTML tags and their attributes should only be used to mark the structural elements of your documents and CSS should be used to control the layout of those elements. But don't take my word for it, see what w3c has to say about it.

      This is actually related to the problem of why CGI scripts shouldn't have HTML embedded in them (unless it's a simple script). Form and content should be kept distinct. I am constantly working on scripts that have CSS, Javascript, HTML and Perl all tossed together and blended well. Rarely are you working on all of the elements simultaneously. You focus on one at a time and this is tougher to do when their mixed (not to mention what happens when you're asked to change the look and feel of all of the pages).

      Cheers,
      Ovid

      Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

(jeffa) Re: CGI
by jeffa (Bishop) on Dec 22, 2000 at 02:46 UTC
    Read the perldoc on CGI.pm again and look for LIMITED SUPPORT FOR CASCADING STYLE SHEETS

    I tend to supply font and color info in my script, or use templates.

    Jeff

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)