Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
photo of Jennifer Kyrnin

Jennifer's Web Design / HTML Blog

By Jennifer Kyrnin, About.com Guide to Web Design / HTML since 1997

CSS annoyance - or maybe the browser?

Monday November 17, 2008
I was reading this post on smashing magazine the other day and it mentioned using CSS to set your text to uppercase. Sure, I agree with that. After all, that's what the text-transform property is for. But here's something you may not have known. When I did this the other day in a script that was building documents intended to be copy/pasted, I ran into an unexpected snag. In Firefox 3 (and possibly other browsers, I didn't test) when I would copy the transformed text, it would copy it as it was written in the HTML not as it displayed on the Web page. This was extremely frustrating for the people copy/pasting until I figured out what was going on. I ended up hard coding the all-caps sections just so they would copy and paste correctly.

Comments

November 17, 2008 at 11:43 am
(1) Wardell says:

That is an annoyance. Maybe JavaScript could have been used to rewrite the necessary strings?

November 17, 2008 at 7:44 pm
(2) Dave says:

I believe this behaviour is correct.

‘text-transform’ is a style. You don’t get bold or underlined text with copy/paste either.

The only text that should be uppercase in the source code is acronyms like ‘HTML’ and the first letter of a sentence. If you hard code anything else, it won’t make sense to screen-readers.

November 17, 2008 at 8:19 pm
(3) Alexander says:

I personally don’t care what case my documents are copy-pasted in. If the Readers want that uppercase so badly they can fix it by themselves, or just download the HTML page.

November 18, 2008 at 3:57 pm
(4) Jennifer Kyrnin says:

Andrew: True. Normally I don’t care what case it’s copied into. But the point of the application I was building was to generate a text document at the end for the user to save and use. And the case of the elements had meaning within the text document.

So yes, normally I wouldn’t care at all, but in this situation I had to care, and the way CSS works (as Dave says, the behavior is correct - CSS styles the underlying text it doesn’t change it) didn’t work for the application.

The main reason it was an annoyance was because I hadn’t tested the results through to the very end and had to deal with confusing (at first) complaints because the text wasn’t capitalized correctly. “but it is capitalized” “not in our reports” “on the Web page it is - OH WAIT!…” :-)

November 18, 2008 at 4:42 pm
(5) Martyn P says:

Well, in your case, then, I would say that you should be hard-coding it, not styling, if it’s semantically required to be in upper case.

December 2, 2008 at 8:52 am
(6) ailaG says:

And when you copy bold text into Notepad? It doesn’t come out bold, isn’t that an annoyance?

How about when you copy a text with an tag and it comes out just regular on Notepad?

When you copy paste you lose some properties. Microsoft Word hardly keeps any of the CSS according to my experience. Tough. The caps are still part of the design.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore Web Design / HTML

About.com Special Features

Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

©2009 About.com, a part of The New York Times Company.

All rights reserved.