I am coding a JSP/JSTL application. I would like to style a link with the first letter uppercase and the rest lowercase. For example "my LINK" would become "My Link".
I saw that in CSS I can do:
<a href="..." style="text-transform: capitalize">${linkName}</a>
Which works only when ${linkName} is all lower case, but doesn't work as I want when is uppercase for instance if it contains "MY LINK" will be still displayed all uppercase.
I was wondering what is the best way to solve this problem, for instance it could be to use JSTL to convert ${linkName} to lower case.
Anyone knows how to do that? Or any alternative way?
Thanks in advance!
The text-transform CSS property specifies how to capitalize an element's text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized. It also can help improve legibility for ruby.
You can capitalize the first letter of the . qcont element by using the pseudo-element :first-letter . This is the closest you're gonna get using only css. You could use javascript (in combination with jQuery) to wrap each letter which comes after a period (or comma, like you wish) in a span .
You can achieve CSS all caps by using the keyword “capitalize.” In addition, text-transform capitalize converts all the first letters in all words to uppercase. Other values you can use with text-transform include “none,” “lowercase,” “full-width,” and “full-size-kana.”
You can use JSTL functions fn:toLowerCase()
to lowercase a string.
So, this should do
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
...
<a href="..." style="text-transform: capitalize">${fn:toLowerCase(linkName)}</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With