Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

Search:

CA216      CA249      CA318

CA400      CA651      CA668


CSS and SSI

For larger websites, need to organise common code.


CSS

With hundreds or more pages, you will want a common look and feel.


Where to put the CSS:

  1. CSS in external file:
    <head>
    <link rel=stylesheet type="text/css" href="file.css">
    </head>
    

  2. CSS defined inside web page:
    <style>
    ... CSS code ...
    </style>
    

  3. CSS defined for elements of page:
    <a href="file.pdf"><img  style="border:none"  src="Icons/pdf.gif"></A> 
    
    <audio  style="width:80%"  controls>
    
    


Notes:




SSI

With hundreds or more pages, you will want to separate out code that is common to all pages.

SSI (Server Side Include) - drag common code (e.g. header and footer) into every page. Simply include a line like:

<!--#include virtual="/SSI/header.html" -->

Can change header.html and it changes in all pages.


SSI is invisible to client:

SSI at DCU:



SSI Exercise

  1. Make a file.shtml in your web directory:
    cd
    cd public_html
    gedit file.shtml &
    
  2. Insert an SSI line in the file to get it to include another html file.
  3. Test it works. Look at:
    http://student.computing.dcu.ie/~username/file.shtml
    and see that it is including the other file.



Other SSI directives

There are other SSI directives.

One useful one is to echo an environment variable that exists on the server. The text is substituted at this point before the HTML stream is sent to the client:




SSI variables demo

I don't show you the original SSI here but you can guess it.
View Source to see the variables were inserted before the HTML went to the client.


variable meaning value
SERVER_NAME Server name computing.dcu.ie
SERVER_ADDR Server IP 136.206.217.25
REMOTE_ADDR Client IP 107.20.120.65
REMOTE_HOST Client name (none)
HTTP_X_FORWARDED_FOR Client original IP (none)
LAST_MODIFIED This page last modified Friday, 15-Dec-2017 18:09:21 GMT
HTTP_REFERER Referring page (none)
HTTP_USER_AGENT User agent string CCBot/2.0 (http://commoncrawl.org/faq/)



Feeds      w2mind.org

On Internet since 1987.