Jump to content

span first-letter


florynth

Recommended Posts

Hi,I'm trying to change the first-letter element to a capitalize and the rest of the text to lowercase. The information's coming from a database in capital so I cannot (easily) take the first letter and do the job "manually".this is what I go so far

.name{    text-transform:lowercase;}.name:first-letter {    color:#0000ff;    text-transform:uppercase;}

It's not working on a <span> element but it does work in a <div> element... The problem is the line return of the div ! So if I set

div{    display:inline;}

Now the first letter is not afect anymore ?&$%Any suggestion ?

Link to comment
Share on other sites

Here is some sample of what does and doesn't work...This work for the first letter but the second part not on the same line

<html><head><style type="text/css">.test:first-letter{color: #ff0000;text-transform:uppercase;}</style></head><body><p class="test">first part who I want to have the first letter in uppercase</p>Other text who should be on the same line</body></html>

Now the line is on the good place but the uppercase doesn't work...

<html><head><style type="text/css">.text{display:inline;}.test:first-letter{color: #ff0000;text-transform:uppercase;}</style></head><body><p class="test">first part who I want to have the first line in uppercase</p>Other text who should be on the same line</body></html>

And now with a span who's already inline by default...

<html><head><style type="text/css">.test:first-letter{color: #ff0000;text-transform:uppercase;}</style></head><body><span class="test">first part who I want to have the first line in uppercase</span>Other text who should be on the same line</body></html>

It's like if you have a inline attribut the first-letter option is ignore !If there's anyone who's able to confirm me that or the explain what I do wrong !Thank'sp.s. You just have to cut and paste the code section in any try it yourser of the siteTryItYourSelf

Link to comment
Share on other sites

If this capitalizing the text is not working out using CSS, i guess you can use server side scripting for such string manipulation..you had earlier mentioned that you are getting the string from a database, then manipulate it and display in using server side scripting.I tried doing it in asp.net (vb) Dim str As String = "HI FELLAS HOW ARE DOING"str = str.ToLowerstr = str.Concat(str.Substring(0, 1).ToUpper, str.Substring(1, str.Length - 1))response.write(str)Correct me if I am wrong.

Link to comment
Share on other sites

Yes of course it will work that way but I want to use a css as much has I can because I'm using this database access script for many site and for exemple if I put :Hi, we are <p class="date">monday</p> welcome on my site !I don't want the first letter to be capitaliseIf I put :<p class="date">monday</p> is the best day of the week !I will want the first letter to be capitalise so I just have to change my css not my script (If we figure that monday is the result of a database)Of course the exemple is not great but I think you do understand what I meantMartin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...