Forums

Can I insert text with CSS? (11 posts)

  1. strunk
    Member
    Posted 3 years ago #

    Hey ya,
    Thanks for the explaination of the ins tag. I would like to have anything I write inside an ins tag always be prefaced with "Inserted time --" without always having to type that. Is there a CSS hack that will let you define the ins tag to always display this preface text? (Once can do this in Microsoft Excel with a "special number format", so that the number 1 would appear as "1 ringy-dingy" for example.)

  2. podz
    Support Maven
    Posted 3 years ago #

    You could make a Quicktag do that ?
    http://www.mfr.f2s.com/quicktags/

  3. carthik
    Member
    Posted 3 years ago #

    But there is already a quicktag for ins :)
    He want's the ins tag's contents styled and displayed, which I don't think is easy. I mean the tag's contents are not displayed, right?

  4. strunk
    Member
    Posted 3 years ago #

    Yeah, I would guess that maybe this is something to be done with PHP rather than with CSS, since CSS is supposed to be presentation, seperated from content. But while I know some CSS, I know no PHP.

  5. podz
    Support Maven
    Posted 3 years ago #

    You know, I have no idea ..... I might play with that later then.

  6. strunk
    Member
    Posted 3 years ago #

    OK, it looks like it can maybe be done with the :before pseudo-element:
    http://www.webmasterworld.com/forum83/3891.htm
    THat would be pretty cool. I don't know if there'd be a way to insert a variable corresponding to the date, but it looks like I could at least insert "Update--" or something like that.
    Here's a ref from the W3C:
    http://www.w3.org/TR/REC-CSS2/selector.html#before-and-after

  7. Anonymous
    Unregistered
    Posted 3 years ago #

    Yes, it can be done in css, but almost no browsers support it (the content property, with before and after psuedo selectors - css3 I do believe).
    So.. php is your way to go. I simple filter installed into WP would work.

  8. Brak
    Member
    Posted 3 years ago #

    using :before and :after and content: will do the trick. No IE though. Only Moz/Opera I believe. Oh... and it's CSS2, just that the IE team felt that it was not prudent to include many CSS2 functionalities.

  9. Millennium
    Member
    Posted 3 years ago #

    Actually, the latest IE7 hack adds partial support for :before/:after/:content in IE. Apparently it's still a bit shaky, though.

  10. strunk
    Member
    Posted 3 years ago #

    OK, so you can insert a variable into the :before pseudo-element, as long as it's a variable that is specified inside the HTML tag you are styling with :before.
    Here's my CSS:
    ins:before {
    content: attr(datetime);
    }

    And here's my output:

    2004-7-25T13:29:52-4:00 Now with bonus Velvet Underground reference!

    If I'm reading the W3C spec right, I can have either a variable (one variable) or text, but not both. Also, I wonder why the ins tag is returning last month instead of this month? Anyway, that's pretty neat.
    Here's the W3C ref:
    http://www.w3.org/TR/REC-CSS2/generate.html#content

  11. DennisWilliamson
    Member
    Posted 3 years ago #

    Here's the IE7 hack referred to above.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags