For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2006 > 'use CGI' with stylesheets not working in Firefox









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author 'use CGI' with stylesheets not working in Firefox
Nik J

2006-07-26, 6:57 pm

My stylesheet is not showing up in Firefox but is in IE, for the
following code:

#!/usr/bin/perl
use warnings;
use strict;
use CGI qw(:standard);

print header();
print start_html(-title => 'TEST',
-style => { -src => [ qw( test.css ) ] } );

print a({href => '#'}, "link should be bold");

print end_html();

__END__

and in the test.css is:
a { font-weight: bold; }


now the source from the resulting page is:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-US"><head><title>TEST</title>
<link rel="stylesheet" type="text/css" href="test.css" />
</head><body><a href="#">link should be bold</a></body></html>

Now if I remove the <!DOCTYPE> tag from the html, it displays fine in
Firefox and IE. That tag is generated from the start_html() function
from CGI.

So how do I use the start_html() function in the CGI module to have
firefox display the page correctly? Is this a bug in FF? I have checked
the page on some co-worker's FF and IE.

Are the parameters in DOCTYPE wrong? if so how do I correct it?

Using perl 5.8.4 on a Solaris 2.6 machine.

Any help is greatly appreciated,
Nik J

Nik J

2006-07-27, 6:57 pm

It seems the only DTD DOCTYPE that Firefox 1.5.0.4 would use the proper
CSS is when it was set to the HTML 3.2


Here is what I changed the start_html to:

print start_html(-title => 'TEST',
-dtd => [ '-//W3C//DTD HTML 3.2//EN' ],
-style => { -src => [ qw(test.css ) ] },
);

Which now works in both FF and IE, perhaps I should log this as an
issue with the FF group, but I'm not sure of standards associated with
DOCTYPE.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com