

How to combine Bold and Italic in CSS ?
source link: https://www.geeksforgeeks.org/how-to-combine-bold-and-italic-in-css/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

In this article, we will learn how to combine bold and italic in CSS. Italic and bold are two text styles that are utilized to emphasize or draw attention to words or phrases. Bold text gives a darker appearance to the text while italic text adds a cursive effect.
Syntax
Below are the 2 possible approaches where the bold and italic text styles can be combined:
// 1st Approach .class { font: bold italic; } // 2nd Approach .class { font-style: italic; font-weight: bold; }
Using the font Shorthand Property
The font property is a Shorthand Property that enables you to set font-related attributes suchas style and weight in a declaration.
Approach
- In the CSS code, for the bold italic text class is given within the <style> tag in the <head> section.
- This code applies an italic font style, weight and potentially a color to enhance visibility.
- In the <body> section you can see examples of using the bold italic text class for paragraphs by enclosing them within <p> tags.
Example 1: In this example, we will see how to combine bold and italic styles for text using font property in CSS.
<!DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content=" width = device -width, initial-scale = 1 .0"> < style > body { margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f0f0f0; } .gfg { margin: 20px auto; padding: 40px; background-color: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); border-radius: 20px; } .bold-italic-text { font: bold italic 24px Arial, sans-serif; color: #4CAF50; } </ style > < title >GeeksforGeeks</ title > </ head > < body > < div class = "gfg" > <!-- HTML using the bold-italic-text class --> < p class = "bold-italic-text" > A Computer Science portal for geeks. </ p > </ div > </ body > </ html > |
Output:

Using font-style and font-weight Properties
To combine the bold and italic text style in CSS, the font-style and font-weight properties can be implemented to the element.
Approach
- Create the HTML element <div> and <p> in the HTML document. Use Internal stylesheet to write CSS code.
The element having class named ".bold-italic-text"
defines the CSS properties including italic and bold the text.- It sets the font size to 16px with font family to Arial or sans-serif, and text color to #4CAF50 (a shade of green).
Example 2: The method used to merge italic styles is to apply the style and font weight properties.
<!DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content=" width = device -width, initial-scale = 1 .0"> < style > body { margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f0f0f0; } .gfg { width: 600px; margin: 20px auto; padding: 40px; background-color: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); border-radius: 20px; } .bold-italic-text { font-style: italic; font-weight: bold; font-size: 16px; font-family: Arial, sans-serif; color: #4CAF50; } </ style > < title >GeeksforGeeks</ title > </ head > < body > < div class = "gfg" > <!-- HTML using the bold-italic-text class --> < p class = "bold-italic-text" > Welcome To Geeksforgeeks!! </ p > </ div > </ body > </ html > |
Output:

Recommend
-
12
The bold beauty of content prototypes Published on 30.11.2016, by Thomas ByttebierA little over half a year ago I joined the dig...
-
17
Being Bold, Global, and Personal I presented the closing keynote at the Design for America (DFA) Summit 2019 just...
-
11
I took the rather bold step today 2005-04-13 by qntm I took the rather bold step today...
-
2
Built With MongoDB: ItalicDerek Tu and Jeremy Cai, two high school friends from the Chicago suburbs, began aspiring to become e...
-
7
Windows Terminal 1.9 to get Quake Mode and italic version of Cascadia Code fontMicrosoft recently announced Windows Terminal 1.9 (Preview) that adds some new features and improvements. If you are a fan of Windows Terminal, you can now...
-
2
Get ahead VMware offers training and certification to turbo-charge your progress. Learn more Get support Spring Runtime offers support and bin...
-
10
I Asked an AI Robot to Generate 200-Year-Old Woodcuts of Mount DiabloThe results? Mind-boggling
-
4
A Bold Font for Retro Designs and More September 9, 2022 ...
-
13
January 03, 2023 link Bold (and sometimes boring) Predictions for Apple in 2023 Jus...
-
5
accessibility Don't fake bold and italic text with Unicode ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK