Font style of the string using JavaScript:
JavaScript provide the string object methods to change the style of the string.
String Object methods: These are the following methods to change the style of the string.
- big()
- blink()
- bold()
- fixed()
- fontsize()
- fontcolor()
- italics()
- link()
- small()
- strike()
- sub()
- sup()
- toLowercase()
- toUppercase()
See the following example to understand the use of the above method.
Example:
<html>
<head>
<title>Sting Style</title>
</head>
<body bgcolor="#cccccc">
<script type="text/javascript">
var text="Good Morning!"
document.write("<p>Bold: " + text.bold() + "</p>")
document.write("<p>Fixed: " + text.fixed() + "</p>")
document.write("<p>Strike: " + text.strike() + "</p>")
document.write("<p>Small: " + text.small() + "</p>")
document.write("<p>Big: " + text.big() + "</p>")
document.write("<p>Italic: " + text.italics() + "</p>")
document.write("<p>Fontsize: " + text.fontsize(16) + "</p>")
document.write("<p>Fontcolor: " + text.fontcolor("maroon") + "</p>")
document.write("<p>Blink: " + text.blink() + " (does not work in IE)</p>")
document.write("<p>Lowercase: " + text.toLowerCase() + "</p>")
document.write("<p>Uppercase: " + text.toUpperCase() + "</p>")
document.write("<p>Subscript: " + text.sub() + "</p>")
document.write("<p>Superscript: " + text.sup() + "</p>")
document.write("<p>Link: " + text.link("http://www.dotnetheaven.com") + "</p>")
</script>
</body>
</html>
Output: Output of this script is as follows:
Figure: String in different style.