chagnie
chagnie

Reputation: 23

Text variable in css

I am maintaining a simple website that publishes information. Most of the information is static, but there are some dates that change periodically. These dates are listed on various pages of the site and I would like to simplify the updating.

In principle, I would like to define a variable, say @date (or whatever format I need) that I could substitute at every place that it appears and only define it once. I suppose the simplest(?) would be to use javascript, but the site does not use that otherwise, so I thought it is kind of like shooting a robin with a canon.

So, my question is, is it possible to do something like this using only html and css?

Thank you!! ps: I am not a programmer, I am doing this as volunteer work.

Upvotes: 2

Views: 106

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201508

There are no variables in HTML, because HTML is not a programming language. You need to use authoring tools that let you generate HTML so that e.g. some data in copied into different places, or maybe some information is automatically inserted (e.g., date of last update). For example, if PHP is available on the server, you could use it.

Upvotes: 0

sachleen
sachleen

Reputation: 31121

HTML:

<p>This is my content. Some event will happen on <span class="date1"></span>.</p>

CSS:

.date1:before {
  content: '12/30/2012';
}

Demo

Docs on :before selector

Although I wouldn't mix my content with CSS like this... It'll work.

Upvotes: 2

Related Questions