in reply to Mixing css with html
Consider exactly how CSS works. The server sends down an HTML page which contains, among other things, a reference to a stylesheet (in the form of another URL). The user’s browser now makes a separate HTTP request for that CSS file if it does not already have a copy in its cache.
While it is certainly possible for your (Perl) application to serve a copy of the CSS-file, since it is a static file it is much more common practice to simply arrange for Apache to serve up the contents of the file directly.
Or both... Consider the slightly-unusual technique used by Perlmonks itself, which you can easily see by examining the source code of, say, the page you are looking at right now. When I did this, I saw the following two lines:
<link rel="stylesheet" href="/css/common.css" type="text/css" /> <link rel="stylesheet" href="?node_id=204962" type="text/css" />
The PerlMonks web-server is giving your browser two places from which it (your browser...) should now retrieve CSS information. The first is probably a reference to a static directory, defined by a <directory> directive somewhere deep inside httpd.conf in such a way that Apache will simply deliver the content of an existing file as-is. But the second is obviously a request that will be served by the Perl executable that runs the site. There’s a node out there (everything in PerlMonks is a numbered node), and it is node #204962, and it contains CSS. (If you are so inclined, you can type either of these URLs (properly prefixed by the website URL in your case) into the address-bar of your web browser, and look at what they contain. That’s exactly what your browser did do, and a copy is sitting in your browser’s local cache right now.) Your browser doesn’t care: it sent a URL, Apache did the right thing, and somebody-or-other somehow-or-other sent back a file.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Mixing css with html
by ww (Archbishop) on Apr 18, 2011 at 03:34 UTC |