
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to set whether the style of the font is normal, italic or oblique with JavaScript?
To set the style of the font, use the fontStyle property. You can try to run the following code to set the style of the font to normal, italic or oblique with JavaScript −
Example
<!DOCTYPE html> <html> <body> <h1>Heading 1</h1> <p id="myID"> This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. </p> <button type="button" onclick="display()">Set Font Family and Style</button> <script> function display() { document.getElementById("myID").style.fontFamily = "verdana,sans-serif"; document.getElementById("myID").style.fontStyle = "italic"; } </script> </body> </html>
- Related Articles
- Set the font style with CSS
- How to set the boldness of the font with JavaScript?
- How to set the font size of text with JavaScript?
- Make a font italic with CSS
- How to set the style of the top border with JavaScript?
- How to set the style of the right border with JavaScript?
- How to set the style of the bottom border with JavaScript?
- How to set the style of the left border with JavaScript?
- How to set the font family for text with JavaScript?
- How to set whether or not an element is resizable by the user with JavaScript?
- How to set the font style to Bold in Python Plotly?
- How to set the style of the rule between columns with JavaScript?
- How to set the style of the outline around an element with JavaScript?
- How to set whether the text of an element can be selected or not with JavaScript?
- How to set whether the image-border should be repeated, rounded or stretched with JavaScript?

Advertisements