We've got a client who want's to superscript to "registered trademark" (®) character across their website.
The website is CMS based and not only are they having trouble consistently superscripting characters but the superscript styling doesn't carry across to any CMS generated page titles etc.
I'm wondering what are the possible/ best ways to achieve this:
- Can CSS be used to apply a style to a specific special character?
- Using jQuery to apply the style post page load.
- Extending the template parsing engine (Silverstripe)
Any ideas are appreciated.
<span></span>
tags with that css class appliedStrictly speaking you cannot create "super-script" with any single CSS property (there is veritcal-align "super", but it doesn't change the size or style of the characters, only it's position relative to the text baseline). However, there are ways to accomplish this successfully that I have tried before.
First of all, as the two other posters have mentioned, you'll need to target the symbol somehow. If you can wrap all
®
characters with markup, then the rest can be easily done with CSS. For example:When you have
<sup>®</sup>
you can simply add these styles to your stylesheet to get a desired effect: Here's an example: http://jsfiddle.net/jglovier/vqHuu/
Of course, if you can't access the markup like this, you'll need to use jQuery to look for the characters and wrap them in a
<sup>
tag as other's have suggested.I dont believe it can be done with CSS alone.
I would use jQuery to find and replace the
®
content with<sup>®</sup>
There is a similar question below with a correct answer on how to do this (saves me the trouble):
Altering registered symbols (R)
Unfortunately, I don't think you can just select certain characters with only CSS.
However...
There is a CSS rule for superscript, and it is:
This jQuery works:
I hope this helps!
In the PHP code, you can put this into your Page class to do what you want on the server side:
$Content
in the template engine will first look for$page->Content()
(the method) and if that doesn't exist will look for$page->Content
. By contrast, the CMS editor only looks for$page->Content
. This means that by defining aContent()
method that processes the output, you can include code that is only executed on template display and doesn't muck with the CMS.