Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

HTML & CSS IntroductionChapter 11. CSS: Styling Text and Images

font-weight and font-style

font-weight and font-style

Adjusting Font Weight and Style in CSS

The font-weight property is used to set the thickness of fonts. The font-style is used to set italic or oblique font.

font-weight

You can specify font-weight with weight numbers or keywords.

Weight numbers

For numbers, you can select from nine sets of numbers from 100 to 900. The smaller the number, the thinner the font becomes. When you specify a number, you need to make sure that the font with the specified weight is available. If the specified weight is not available, a browser chooses an alternative.

Keywords

The default is normal which is equivalent to 400 font weight. bold is equivalent to 700 weight. You can use lighter or bolder fonts. Actual weights selected with those keywords depend on the parent font-weight. If you use lighter, a browser finds a font thinner than the parent's font. If you use bolder, a browser finds a font thicker than the parent's font.

font weight and font style

Idea<b> and <strong> tag

Bold can also be implemented directly by HTML. The <b> tag is used to simply bold the selected part without adding any meaning. The <strong> tag has a semantic to stress that the selected part is important for the page.

Practice 1

Objective:
Test different font weights

1. Update the body section of the HTML file

Add the code below at the end of the <body> section in the chapter11.html file. In this code, we are listing all weight numbers and keywords.

chapter11.html
<h2>Font Weight</h2>
<p>Font Weight: Original</p>
<p style="font-weight: 100;">Font Weight: 100</p>
<p style="font-weight: 200;">Font Weight: 200</p>
<p style="font-weight: 300;">Font Weight: 300</p>
<p style="font-weight: 400;">Font Weight: 400</p>
<p style="font-weight: 500;">Font Weight: 500</p>
<p style="font-weight: 600;">Font Weight: 600</p>
<p style="font-weight: 700;">Font Weight: 700</p>
<p style="font-weight: 800;">Font Weight: 800</p>
<p style="font-weight: 900;">Font Weight: 900</p>
<p style="font-weight: lighter;">Font Weight: lighter</p>
<p style="font-weight: bolder;">Font Weight: bolder</p>
<p style="font-weight: bold;">Font Weight: bold</p>
<hr>

2. Check the result with a browser

  • Open chapter11.html with a browser.
  • Although Roboto fonts we set exclude 200, 600, and 800 weights, the browser renders those elements using alternative font weights. (200, 600, and 800 are replaced with 100, 700, and 900 respectively in this case.)

You can also check the sample result here (Demo Site).

link

font-style

font-style is primarily used to change font style to italic or oblique. Oblique is a font style slightly inclined to the right based on a regular font. The italic font looks very similar to the oblique font; however, some design adjustments are added to the italic font. Practically, you can choose italic or oblique based on font availability.

Keywords

The default is normal. You can use italic for italic font style and oblique for oblique font style.

Idea<i> and <em> tag

Italic font can also be implemented directly by HTML. The <i> tag is used to simply change the selected part to italic without adding any meaning. The <em> tag has a semantic to stress that the selected part is important for the page.

Practice 2

Objective:
Try to set italic fonts using various approaches.

1. Update the body section of the HTML file

Add the code below at the end of the <body> section in the chapter11.html file. In this code, we are changing fonts to italic using CSS (the font-style property) and HTML (the <i> tag and <em> tag).

chapter11.html
<h2>Font Style</h2>
<p style="font-weight: 400; font-style: italic;">Font Weight & Style: 400 Italic (CSS)</p>
<p style="font-weight: 400;">
  <i>Font Weight & Style: 400 Italic (HTML i tag)</i>
</p>
<p style="font-weight: 400;">
  <em>Font Weight & Style: 400 Italic (HTML em tag)</em>
</p>
<hr>

2. Check the result with a browser

  • Open chapter11.html with a browser.
  • You can see that the different sets of code provide the same results.

You can also check the sample result here (Demo Site).

link


You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Mouse Over Tooltip CSS

Mouse Over Tooltip CSS

AI Coding Tools

AI Coding Tools

CSS Variable: Creating CSS Custom Properties

CSS Variable: Creating CSS Custom Properties

Bridging HTML and CSS: Key Concepts for Web Designers

Chapter 7. Bridging HTML and CSS

Mouse Over Tooltip CSS

Mouse Over Tooltip CSS

AI Coding Tools

AI Coding Tools

CSS Variable: Creating CSS Custom Properties

CSS Variable: Creating CSS Custom Properties

Bridging HTML and CSS: Key Concepts for Web Designers

Chapter 7. Bridging HTML and CSS

Tags:

Text Styling

Font

HTML & CSS Introduction
Course Content

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;