in reply to Adding Style to a table.

You can use style defined in external or internal style sheets. Here is how:

use CGI qw/:standard :html3/; # here's a stylesheet we will incorporate directly into the page $new_style = ' <!-- .big_red { font-size: 30pt; font-family: sans-serif; color: red; } -->'; print header(); print start_html( -title=>'CGI.pm using CSS', -style=>{-src=>'http://somesite.com/style.css', -code=>$new_style} ); print table({-border=>2, -class=>'big_red'}, caption('When Should You Eat Your Vegetables?'), Tr({-align=>CENTER,-valign=>TOP}, [ th(['Vegetable', 'Breakfast','Lunch','Dinner']), td(['Tomatoes' , 'no', 'yes', 'yes']), td(['Broccoli' , 'no', 'no', 'yes']), td(['Onions' , 'yes','yes', 'yes']) ] ) ); print end_html;

For more info on CSS click here to Google on.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Adding Style to a table.
by mnlight (Scribe) on Dec 26, 2001 at 10:26 UTC
    What can the problem be with this code? Everything remains the same but the font resorts back to the default color black.
    $THEAD = ' <-- .thead { font-size: 10pt; color: #99FF99; } -->'; $sth->execute (); print $query->header(); print $query->start_html (-title=>'Roster of Players', -style=>-code=>$THEAD); print $query->h1({-align=>'CENTER'}, font({-color=>'9933FF'}), '1990 M +NLIGHTNING ROSTER'); print $query->table({-ALIGN=>'CENTER', BOARDER=>'',-class=>'thead'}, Tr({-bgcolor=>'#9933FF', -valign=>'TOP'}, [ th({-width=>'150'}, 'COACHING').th({-width=>'150'}, 'STAFF'), ] ) );

      There are three errors in your code. First <-- is not the start of an HTML comment <!-- is. Next you need to pass a hash reference to -style. Finally it is -BORDER nor BOARDER.

      use CGI ':all'; $query = new CGI; $THEAD = ' <!-- .thead { font-size: 10pt; color: #99FF99; } -->'; print $query->header(); print $query->start_html (-title=>'Roster of Players', -style=>{-code=>$THEAD}); print $query->h1({-align=>'CENTER'}, font({-color=>'9933FF'}), '1990 M +NLIGHTNING ROSTER'); print $query->table({-ALIGN=>'CENTER', -BORDER=>'0', -class=>'thead'}, Tr({-bgcolor=>'#9933FF', -valign=>'TOP'}, [ th({-width=>'150'}, 'COACHING').th({-width=>'150'}, 'STAFF'), ] ) );

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print