0

I have text that is repeated on multiple pages. Is it possible have the text in the external css page so I only have to change it one time?

6
Contributors
8
Replies
10
Views
7 Years
Discussion Span
Last Post by mariko
0

If with text you mean content, than no. CSS is for styling only. Don't know how your site is built and what technologies you use, but some kind of templating would solve your problem.

1

server side includes are designed for just this situation.

You have a choice of methods but most reliable these days is using PHP.

So if you have a little bit of text (or even lines of code) in a text file.
e.g. incsometext.txt (you can call this anything you like to fit in with your naming conventions)

...then in every place that you want the text you call the file with:

<?php require_once('incsometext.txt'); ?>

(Just in case you didn't know... a page that uses PHP has to end with .php instead of .htm)

Edited by prixat: n/a

1

Actually you can have content via css. It's called the content property and it's used with after: and before: pseudo-elements. However, IE (it's always IE, isn't it?) only supports it from version 8.

e.g.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
div.content:after {content: "Roll up, roll up";}
</style>
</head>

<body>
<div class="content"></div>
</body>
</html>
Votes + Comments
Never come across it ...
0

Thought I should clarify my post somewhat. css content is probably not the way to go. I, personally would not use it as there are so many users without v8+ of IE. Grr, pesky Microsoft! I'd go along with pritaeas - a templating system is what you're looking for - this can be as simple as having include files (require/include) or as complicated as a full-blown templating system (smarty, rain tpl etc). Anyway, I just wanted to suggest - don't use the css option for a year or so, until IE8 uptake by IE users is close to saturation (might never happen!).

Edited by diafol: n/a

0

(Just in case you didn't know... a page that uses PHP has to end with .php instead of .htm)

Just so you know, this is not true. On apache you can use any extension you want and treat it as a php file.

1

Just so you know, this is not true. On apache you can use any extension you want and treat it as a php file.

Just so you know, this is often functionally true. apache server is configurable, however, many servers, particularly low end hosting packs, are locked down
/* addhandler server-parsed is disabled */
so that configuration cannot be changed,

plan on the worst, and you get pleasant surprises when you find the result is better than you expect
plan on the best, and the only surprises are unpleasant

Edited by almostbob: n/a

Votes + Comments
Point taken
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.