Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Html Template CSS and CGI PERL

by Anneq (Vicar)
on Dec 28, 2004 at 14:35 UTC ( [id://417778]=note: print w/replies, xml ) Need Help??


in reply to Html Template CSS and CGI PERL

Put a link element in the header of your template file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title><TMPL_VAR NAME=TITLE></title> <base target="_self"> <link rel="stylesheet" type="text/css" href="External.css"> </head> <body> .... </body>

You could go a step further and dynamically change your stylesheet by using a template variable for the sytlesheet filename.

For even more flexibility, use template toolkit instead of HTML::template. This would give you the ability to put variables in a stylesheet file, which would be processed before rendering to the browser:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title>$Page.title</title> <base target="_self"/> <style type="text/css"> <!-- @import 'path/to/css/main.css'; [% PROCESS "path/to/css/theme.css" %] body { font-size: ${font_size}pt; } p { font-size: ${font_size}pt; } --> </style> </head> <body> .... </body> </html>

In the above example, the main stylesheet is imported, a stylesheet with variables (theme.css) is included, and then additional styles are explicitly added to override those in the first two stylesheets.

A drawback with this method is that the styles from theme.css show up when a user looks at the page source, because those styles get embedded in the html document.

Anne

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://417778]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found