Search code examples
htmlcsstagsitalics

css to force italics for certain characters only within a tag?


Is this possible? Basically, I want to be able to set up a tag that says "within this tag, a-z go into italics, but nothing else does." Or similarly for a-z and A-Z.


Solution

  • CSS is meant to style the structure of the page not the content of the page directly.

    This being said, there are a couple of ways around it (obviously):

    1. Wrap the characters you want to italicize in <i>,<span>,<em>,<dfn>,<var>,<cite>
    2. Use javascript to search through all of you text and wrap any of these elements around that text
    3. use the server side code to split you text into an array and format the text with the tags on the server side so when the content makes it to the page it is already formatted.

    There is no way to pick specific characters using CSS.