in reply to cgi and css, body tag not recognize

1. You must print() the output of $q->start_html.

2. Are you sure the href to the css is correct?

This works:

test.pl:

#!/usr/bin/perl -w use strict; my $q =CGI->new; print $q -> start_html(-title => "bla", -style => { -src => 'test.css' +, -type => 'text/css', -media => 'screen' });
test.css is your css.

$ perl -MCGI test.pl >test.html Open test.html in firefox.

Replies are listed 'Best First'.
Re^2: cgi and css, body tag not recognize
by yvan (Novice) on Jun 14, 2007 at 20:14 UTC
    when the .html is display in firefox, the background colour is not changed. All the others classes in the css file work fine but not the body.
        ok find my solution
        thank you very much for helping me
        in the css file i put the backgroud-color after the background and it worked
        background: url(images/vbc.jpg) no-repeat fixed top right; background-color: #0e7aef;
        thank you Joost
        I did
        perl -MCGI index.cgi > test.html
        this is index.cgi
        #!/usr/bin/perl -w use strict; use diagnostics; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI::Pretty; use DBI; warningsToBrowser(1); my $q = CGI->new(); my $title = "mt Annotation pipeline"; print $q->header(), $q -> start_html(-title => "$title", -style => { -src => 'mycss/mtannot.css', -type + => 'text/css', -media => 'screen' }), $q->div({-class=>"header"},$title), $q->div({-style=>"float: left"}, $q->div({-class=>"menu"}, $q->h3("menu"), ("here is some text"), $q->br(), ("spanning two lines") ), ), $q->div({-class=>"content"}, $q->h1('First Upload your sequence'), $q->table ( {bgColor=> "blue", -border=>1}, $q->TR([ $q->td("1") . $q->td("A") . $q->td("2") . $q->td("B" +), ]), $q->TR([ $q->td("1") . $q->td("A") . $q->td("2") . $q->td("B" +), ]), ), ), $q -> end_html();
        and this is the css file:
        BODY { background-color: #0e7aef; color: white; font-family: sans-serif; background: url(images/vbc.jpg) no-repeat fixed top right; } LI { margin-bottom: 1ex; } H1 { color:black; } .header { font-size: 4em; border: solid thin black; background-color: #8B475D; text-align: center; padding-top: 0px; margin: 0px 0px 10px 0px; color: #7FFF00; width: 90%; } .content { margin-left: 16em; padding: 1em 1em 1em 1em; background-color: #eee; border: solid thin black; width: 75%; } .menu { background-color: #b3d5ff; width: 15em; border: solid thin black; text-align: center; color: black; }
        How do you change the body' background-color in your css?