Reputation: 183
I'm wondering it if is possible to display text on a HTML page from a CSS file.
For example for a web host instead of having 100MB display on a plan upon 4 pages and not having to edit each one but the CSS itself.
For example:
CSS
100MB
and than in text
Our plan has {text from css displays here}
Thanks
Upvotes: 1
Views: 954
Reputation: 26878
You can use the :after
pseudoselector. Suppose your "our plan has" part has an ID planid
, and your HTML looks like this:
<div id = "planid">Our plan has</div>
Then you can do this in the CSS:
#planid:after {
content: ' 100MB'; /*what the element will contain*/
display: inline; /*it's inline*/
/*more styling*/
}
The :after
selector creates a pseudo-element after the selected element. To create one before it, use the :before
selector.
Little demo: little link.
Upvotes: 6
Reputation: 18411
CSS is not designed to do that kind of work, it's for organizing styles and not for managing contents.
What you need is a variable to store your value and then show it many times. So you need PHP, JS, Ruby, Java or your favourite language.
Upvotes: 2
Reputation: 13947
you can do this using pseudo elements like :after - http://jsfiddle.net/spacebeers/LQy7T/
.your_class:after {
content: "YOUR TEXT";
color: red;
background: blue;
display: inline;
}
Upvotes: 2
Reputation: 32142
Used to after before
properties
yes do this as like this
HTML
<div>Hello</div>
Css
div:after{
content:'100mb';
}
Upvotes: 3