{"id":84,"date":"2026-04-07T01:11:07","date_gmt":"2026-04-07T01:11:07","guid":{"rendered":"https:\/\/gigz.pk\/css\/?post_type=lesson&#038;p=84"},"modified":"2026-04-20T11:26:27","modified_gmt":"2026-04-20T11:26:27","slug":"fonts-and-font-families-in-css","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/","title":{"rendered":"Fonts and Font Families in CSS"},"content":{"rendered":"\n<p>Fonts play a very important role in web design. They control how text looks on a website and help improve readability, style, and user experience. Choosing the right font makes your content more attractive and easier to understand.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What are Fonts<\/h3>\n\n\n\n<p>A font is the visual appearance of text. It includes the style, size, and design of letters. In CSS, you can control fonts using different properties.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is Font Family<\/h3>\n\n\n\n<p>A font family is a group of related fonts. It allows you to define a list of fonts so the browser can choose the best available option.<\/p>\n\n\n\n<p>Example of font family in CSS<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">p {<br>  font-family: Arial, Helvetica, sans-serif;<br>}<\/pre>\n\n\n\n<p>In this example, the browser will try Arial first. If it is not available, it will use Helvetica, and if that is also not available, it will use a default sans-serif font.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Types of Font Families<\/h3>\n\n\n\n<p>There are five main types of font families in CSS.<\/p>\n\n\n\n<p>Serif fonts<br>These fonts have small lines at the ends of characters. They look traditional and formal. Example Times New Roman<\/p>\n\n\n\n<p>Sans-serif fonts<br>These fonts do not have extra lines. They look clean and modern. Example Arial<\/p>\n\n\n\n<p>Monospace fonts<br>All characters take equal space. These are often used in coding. Example Courier New<\/p>\n\n\n\n<p>Cursive fonts<br>These fonts look like handwriting. They are more decorative.<\/p>\n\n\n\n<p>Fantasy fonts<br>These are creative and artistic fonts used for special designs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Font Properties in CSS<\/h3>\n\n\n\n<p>CSS provides several properties to control fonts.<\/p>\n\n\n\n<p>Font family<br>Defines the font type<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">h1 {<br>  font-family: Verdana;<br>}<\/pre>\n\n\n\n<p>Font size<br>Controls the size of the text<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">p {<br>  font-size: 18px;<br>}<\/pre>\n\n\n\n<p>Font weight<br>Controls how bold the text is<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">p {<br>  font-weight: bold;<br>}<\/pre>\n\n\n\n<p>Font style<br>Used to make text italic or normal<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">p {<br>  font-style: italic;<br>}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Using Google Fonts<\/h3>\n\n\n\n<p>You can also use custom fonts from online sources like Google Fonts.<\/p>\n\n\n\n<p>Step 1 Copy the font link into your HTML file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;link href=\"https:\/\/fonts.googleapis.com\/css2?family=Roboto&amp;display=swap\" rel=\"stylesheet\"&gt;<\/pre>\n\n\n\n<p>Step 2 Use the font in CSS<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">body {<br>  font-family: 'Roboto', sans-serif;<br>}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Best Practices<\/h3>\n\n\n\n<p>Use simple and readable fonts for better user experience<br>Always provide backup fonts in your font family<br>Avoid using too many different fonts on one page<br>Use web-safe or trusted fonts for better compatibility<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>Fonts and font families are essential for creating visually appealing websites. By understanding how to use them in CSS, you can improve both design and readability of your web pages.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/css\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">CSS Fundamentals (Beginner) > Typography &#038; Text Styling > Fonts &#038; Font Families<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1776684361993\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1776684361622\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":0,"template":"","class_list":["post-84","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fonts and Font Families in CSS - CSS learning mastery<\/title>\n<meta name=\"description\" content=\"Learn CSS fonts and font families with easy examples. Improve website typography using proper font styles and design techniques.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fonts and Font Families in CSS - CSS learning mastery\" \/>\n<meta property=\"og:description\" content=\"Learn CSS fonts and font families with easy examples. Improve website typography using proper font styles and design techniques.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/\" \/>\n<meta property=\"og:site_name\" content=\"CSS learning mastery\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-20T11:26:27+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/fonts-and-font-families-in-css\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/fonts-and-font-families-in-css\\\/\",\"name\":\"Fonts and Font Families in CSS - CSS learning mastery\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/#website\"},\"datePublished\":\"2026-04-07T01:11:07+00:00\",\"dateModified\":\"2026-04-20T11:26:27+00:00\",\"description\":\"Learn CSS fonts and font families with easy examples. Improve website typography using proper font styles and design techniques.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/fonts-and-font-families-in-css\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/fonts-and-font-families-in-css\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/fonts-and-font-families-in-css\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/css\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS Fundamentals (Beginner) > Typography & Text Styling > Fonts & Font Families\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/css\\\/\",\"name\":\"CSS learning mastery\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/css\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fonts and Font Families in CSS - CSS learning mastery","description":"Learn CSS fonts and font families with easy examples. Improve website typography using proper font styles and design techniques.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/","og_locale":"en_US","og_type":"article","og_title":"Fonts and Font Families in CSS - CSS learning mastery","og_description":"Learn CSS fonts and font families with easy examples. Improve website typography using proper font styles and design techniques.","og_url":"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/","og_site_name":"CSS learning mastery","article_modified_time":"2026-04-20T11:26:27+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/","url":"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/","name":"Fonts and Font Families in CSS - CSS learning mastery","isPartOf":{"@id":"https:\/\/gigz.pk\/css\/#website"},"datePublished":"2026-04-07T01:11:07+00:00","dateModified":"2026-04-20T11:26:27+00:00","description":"Learn CSS fonts and font families with easy examples. Improve website typography using proper font styles and design techniques.","breadcrumb":{"@id":"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/css\/lesson\/fonts-and-font-families-in-css\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/css\/"},{"@type":"ListItem","position":2,"name":"CSS Fundamentals (Beginner) > Typography & Text Styling > Fonts & Font Families"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/css\/#website","url":"https:\/\/gigz.pk\/css\/","name":"CSS learning mastery","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/css\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/lesson\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/media?parent=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}