Forum Moderators: not2easy

Message Too Old, No Replies

Is it possible to display text by using CSS only?

         

SilverLining

12:11 pm on Feb 22, 2007 (gmt 0)

10+ Year Member



How does one display text in CSS? Is it possible?

My problem is that the code I'm getting from XML has no title, so my initial solution was to add the heading in the background image with the help of CSS. It looks fine, but ideally it must be text.

The div has been set to

height: auto;
to ensure it expands according to the content it contains. The background image curves at the bottom so
background-position
is set to "bottom". So if the content inside the div is only a few lines in height, the top title embedded in the background image will not be displayed. The top title and bottom curve will only be seen if the content height is equal to (or > than) the height of the background image.

Example code of background used in CSS:

background: url(blah.gif) #fff 0% 100% no-repeat;

It's easy to solve if the title is embedded in the image - just create a seperate div for bottom bg image - but how can I display text in CSS? Should be an easy fix if possible.

Let me know if this is unclear. Thanks.

Fotiman

4:01 pm on Feb 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




How does one display text in CSS? Is it possible?

CSS is for Presentation, not Content. You should try to correct the problem where the problem actually lies (your XML) instead of trying to hack it. Just as I wouldn't use a screwdriver to pound in a nail, nor should you use CSS to create content.

appi2

4:27 pm on Feb 26, 2007 (gmt 0)

10+ Year Member



You could use the :before and :after pseudo-elements.

eg

div:before {content: "woohooo it works"}
or
div:after {content: "goood eh?"}

but you would have to get the rest of the world to use opera or FF2. Good old IE7 says it doesn't want to play.

Matt Probert

6:44 pm on Feb 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good old IE7 says it doesn't want to play

Thank heavens for that! CSS is for suggesting presentation, not for providing content!

Matt

SilverLining

3:53 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



Thanks. Yes, trying to sort this in CSS was not clever!