2

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.

1
  • you can have a header/footer in the CSS and just change the CSS. in either case, we need more info Commented Dec 31, 2012 at 4:22

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

10 Comments

Apparently I don't have enough reputation to vote up this answer and it is not old enough to accept it yet. I will do both as soon as I can. Thank you!
No problem, glad I could help. If you have to do more of this stuff definitely look into a JS solution than CSS. it's much more suited for dynamic content than CSS is.
If you wouldn't mix your content, what would you rather do?
I suppose your comment answers my question: JS
This approach would mean that when CSS is disabled, the content appears as “This is my content. Some event will happen on .” And this is what search engines would see.
|
0

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.

1 Comment

Perhaps it was not clear from my question, but I was looking for a solution that does not involve having to run anything additional, for instance a PHP server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.