Forum Moderators: not2easy
No
Lol :) To expand on that, no you cannot, CSS is to determine the style (presentation) of content, not to define content itself.
Defining content is the job of (X)HTML. And outputting to that medium, Javascript, PHP, ASP, etcetera.
Having said that, within limits, you can put a hyperlink reference in through CSS-through the
content property. The
content property only works in standards-compliant browsers (or, at least, those nearing it) so it will not work in IE 6. But you can do stuff like this: <p id="content-property-example">You can head down to:</p> p#content-property-example:after { content: ' www.spoons.com.au'; } ... while not a particularly practical example (one would argue that the content in the
:after pseudoclass was necessary and required in the markup itself,) that is how it is done. There are limitations - Opera 9.10 (as far as I remember) has the best support for the
:after pseudoclass and the content property, being able to import attribute values of the element, for example: img:after { content: 'Caption: ' attr(title); } ... where this would not work in Firefox 2 (last I checked.)
Some would argue that content is never necessary in CSS - that CSS is for defining presentation, not content - and I tend to agree with them. One thing I do use
content for is in my print styles: when a user prints out a page from one of the websites I've written, it dumps the href value from anchors after the anchor's content itself - thus, a printed document with good reference back to the web if necessary. [edit]Oh, I forgot to mention: the reason I use such a thing in my print styles is degradation: it doesn't impact IE 6 negatively by not supporting it, it doesn't ruin functionality, it is merely "icing on the cake" for those UAs that can support it. I believe that "without CSS, the markup should stand up for itself." - and try to keep that in mind whenever doing CSS-Presentation.
[/edit][edited by: Setek at 11:11 pm (utc) on Mar. 22, 2007]