Skip navigation

You can add content to a web page using css !!!

Using content property in combination with :before and :after pseudo-elements, you can add content to any element. Of course Opera support this with all elements (without pseudo). IE6, IE7 not supports this property.

/* CSS */
#box:before {
content: "This text is before the box";
}
#box:after {
content: "This text is after the box";
}

<!-- HTML -->
<div id="box">I'm inside box</div>
  • Though it is not advisable to generate content using css because css is for presentation, rather use JavaScript for that.
  • You can’t use html inside content; only text.

Note: I posted here because it surprises ME to know css can generate content. My fellow UI friends may aware about this.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: