Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Html Template CSS and CGI PERL

by Anneq (Vicar)
on Dec 28, 2004 at 14:35 UTC ( #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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://417778]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2017-06-29 03:55 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (653 votes). Check out past polls.