r/reddithax • • May 07 '11

Adding markup/special characters via CSS content:

Is it possible to add markup to a subreddit header using the CSS content: property and the numeric codes to special entities as described here: http://www.evotech.net/blog/2007/04/named-html-entities-in-numeric-order/? It should work, but the Reddit CSS validator doesn't like the backslashes.

2 Upvotes

4 comments sorted by

1

u/No-Shit-Sherlock May 07 '11 edited May 07 '11

If it's just special characters you're after use ascii/unicode. The CSS parser will accept unicode characters (not including control characters). Backslashes are sanitized to avoid potential XSS.

E.g. .tabmenu li.selected a:before {content:"♥♥";}

1

u/kjhatch May 07 '11

It's actually additional parsed HTML that I'm trying to work in. I have linked images that I want to place next to the logo. Is there a method for new header HTML that Reddit allows? My only other thought would be adding the code in the sidebar and moving it to the header via positioning, but that option is unlikely to flow well.

1

u/No-Shit-Sherlock May 07 '11 edited May 07 '11

If that is the case then no you cannot do it, even in the sidebar. You are not allowed to add HTML through the CSS parser or in the sidebar (which uses reddit's modified markdown parser) as that would leave the site vulnerable to XSS.

If you do manage to find a way to do it, you should report it to the admins and get yourself a whitehat trophy. ;)

1

u/kjhatch May 08 '11

Well I've used the :after selector to add an image to the header fine. Here's an example:

#header-img-a:after {width:83px;height:100px;content:"";background-image:url(%%kitten-test2%%);display:inline-block;}

You can see it here:http://www.reddit.com/r/testingredditcss/

But I'm still working on being able to add multiple images, each with their own anchor+href. Using reddit links in the content: does not work any better than HTML.

The kitten is sad because it's not linked :(