Forum Moderators: not2easy

Message Too Old, No Replies

Editing a line of text with CSS

throughout whole site

         

consoleob

1:52 pm on Jul 10, 2005 (gmt 0)



I'm totally new to CSS, although I'd like to earn a better understanding of it so I don't continually have to edit every single page (if that is indeed possible!). I run a website, and the copyright notice at the bottom of the page states the year etc, could I alter it with CSS so that it changes throughout my entire website, and then I wouldn't have to change the notice on every single page myself? If so, is it easy to do?

Thanks in advance for any help, and apologies if there's any posts about this elsewhere!

sonjay

2:13 pm on Jul 10, 2005 (gmt 0)

10+ Year Member



It's not css you want for that -- it's includes, either server-side includes or php includes.

In php such an include would look like this:

<?php
include "copyright.htm";
?>

The file copyright.htm would be a text file (not a complete html page) that contains only the appropriate snippet of code to appear at that spot in the page, e.g.:

<p>Copyright 2005 XYZ Company. All rights reserved.</p>

Google up "server-side includes" or "php includes" for more info.

After you've created your includes, you can use your css stylesheet to style them and affect the appearance sitewide by editing one css file.

createErrorMsg

2:30 pm on Jul 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



consoleob, welcome to WebmasterWorld and the CSS Forum.

What you want to do is very possible, but CSS is not the tool for doing it.

CSS is strictly a styling language. It applies properties that control the appearance, layout, and in some limited cases, the behavior, of the html elements in your page's source code.

But it does not control the content of those elements. There are a few, highly limited ways which CSS can add actual content to the page that is not there already, but these applications are both limited in scope and supported by only a few browsers.

The upshot of this being: in order for CSS to effect something on the page, it must first be on the page.

Since you're wanting to add or change the content of your copyright statement, which is an element on the page, CSS is not the technology you need. (Now if you wanted to move the copyright information from the left of the screen to the right, or change it to 20px high, fuchia, bold text, or have it change colors when the mouse moves over it, CSS would be your man.)

What you need, instead, is either (a) some way to have your server deliver the copyright information from one central location to each page on the site before sending it to the browser, or (b) an easy local way to manually change the copyright code on all your pages.

(a) options include SSI (server side includes) or a serverside scripting language (like PHP or ASP) that can store the copyright info in one place and deliver it, when needed, to each page. Bear in mind that either one of these methods will require making changes to the source code of your existing pages. If the copyright is currently hardcoded into all those pages, there's no avoiding going in an pulling it out. Still, these methods work great for expanding sites and adding pages.

In it's best form, these sorts of methods allow you to store ALL redundant information (like headers, footers, sidebars, navigation systems) in seperate files and bring them in as needed. Since this is the CSS Forum, I won't get into the dirty details of how to get thi done. However, check out the following links for more info....

You can ask specific questions about these practices in these forums:
For server side scripting solutions, as in the PHP Forum [webmasterworld.com]
For SSI solutions, ask in the Webmaster General Forum [webmasterworld.com] or HTML and Browsers Forum [webmasterworld.com].

Or check out the results of these searches on WebmasterWorld:
Server Side Includes [google.com]
PHP Includes [google.com]

Also, see the PHP Forum Library [webmasterworld.com], specifically this thread [webmasterworld.com].

(b) options include the use of a search and replace tool that can sift through all the local files on your computer or server and change the information that needs changing. There are some very potent programs capable of doing this. A Google search for "grep tool" turns up some good options.

cEM