2

I have content that is in uppercase ( that's the way it's persisted on the back end ) and I have to transform it into 'proper case'.

I'm finding out that 'text-transform:capitalize' doesn't work. I suspect there's no css based workaround for that either.

.text-test{ text-transform:capitalize; } ... <h1 class="text-test">SOME UPPER CASE TEXT</h1> 

Is my conclusion correct? Thanks

2
  • Capitalise won't work as it targets on the first letter of whatever you're targeting so the rest of the text won't be affected. You'll have to edit it in the HTML or maybe a jQuery solution can be found, Commented Sep 22, 2011 at 15:48
  • 1
    Kyle, please post it as an answer, like to up-vote it. Unless you don't really care ;-) Commented Sep 22, 2011 at 16:05

4 Answers 4

2

Capitalise won't work as it targets on the first letter of whatever you're targeting so the rest of the text won't be affected. You'll have to edit it in the HTML or maybe a jQuery solution can be found,

I care :)

Sign up to request clarification or add additional context in comments.

Comments

2

CSS does not support sentence case conversion. Fix it in the server or you're going to have to use JavaScript to re-write the HTML.

See: How to give sentence case to sentences through CSS or javascript?

Comments

1

Title Case

String.prototype.toTitleCase = function() { return this.replace(/\w\S*/g, function(t) { return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase();}); }; var s1 = "HELLO WORLD!"; alert(s1.toTitleCase()); 

output

Hello World!

This isn't as elegant as a solution that would say convert it to

Hello world!

However I'm sure you can use this as a start point.

Comments

1

Somewhat very (very) late, but can help others.

What about:

.text-test {text-transform: lowercase;} .text-test::first-letter {text-transform:capitalize;} 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.