html - capitalize each letter of word without javascript -
this question has answer here:
- display letters in capitals in block 2 answers
i've written code capitalize first letter of every word in sentence without using javascript. html , css. doesnt seem working. plz solve problem. first code demo works. second code want submit in assignment, plz me solve problem.
code 1:
<html> <head> <input type="text" size="60%" style="text-transform:capitalize"> </head> </html>
code 2:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>untitled document</title> <style> h2{ color:#0f0; font-size:large; font-weight:bold; font-family:"comic sans ms", cursive } p{ color:#0f0; font-size:large; font-family:"comic sans ms", cursive } y{ text-transform:capitalize; } </style> <script language="javascript"> function myfunction(){ var = document.getelementbyid("input").value; document.getelementbyid("output").value = a; } </script> </head> <body> <h1>question 5</h1> <center> <form name=frm1> <table border="2" cellpadding="8" cellspacing="5" style="background-color: blue" width="50%"> <tr> <td align="center" colspan="2"><h2>capitalize first letter of each word</h2></td> </tr> <tr> <td><p>enter text here:</p></td> <td> <x> <input type="text" id="input" placeholder="text here" size="65%"> </x> </td> </tr> <tr> <td align="center" colspan="2"> <y> <input type="text" id="output" placeholder="output" size="100%" readonly> </y> </td> </tr> </table> <input type="button" value="click me" onclick="myfunction()"> </form> </center> </body> </html>
the problem code, written, seems using:
y { text-transform: capitalize; }
it works fine (see fiddle: http://jsfiddle.net/mifi79/a3kqr/) if instead target #output element with:
#output { text-transform: capitalize; }
i'll let tables , strange non-semantic elements (, , etc.) slide since in class , learning ;-)
Comments
Post a Comment