Home » Tech Tutorials » Web Development » CSS » Font Families and Web-safe Fonts

Font Families and Web-safe Fonts

Font Families మరియు Web-safe Fonts

వెబ్ పేజీలో కనిపించే text ఏ రకమైన అక్షర శైలిలో కనిపించాలో నిర్ణయించడానికి CSSలో font-family property ఉపయోగిస్తాము.

font-family అంటే ఏమిటి?

font-family ఒక elementలోని text కోసం font పేరును లేదా fonts జాబితాను ఎంచుకుంటుంది. ఉదాహరణకు font-family: Arial, sans-serif; అని రాస్తే browser ముందుగా Arial fontను ఉపయోగించడానికి ప్రయత్నిస్తుంది.

Arial అందుబాటులో లేకపోతే browser తర్వాత ఇచ్చిన sans-serif fallback fontను ఉపయోగిస్తుంది. అందుకే ఒకటి కంటే ఎక్కువ font names ఇవ్వడం మంచిది.

Web-safe fonts అంటే ఏమిటి?

Web-safe fonts అనేవి చాలా computers మరియు operating systemsలో సాధారణంగా అందుబాటులో ఉండే fonts. ఉదాహరణలు: Arial, Verdana, Georgia, Times New Roman మరియు Courier New.

Font fallback list

Font listలో fontsను commaతో వేరు చేయాలి. సాధారణంగా మొదట specific font, చివరలో generic family ఉంచుతాము.

body {
  font-family: Arial, Helvetica, sans-serif;
}

ఈ codeలో browser ముందుగా Arialను వెతుకుతుంది. అది లేకపోతే Helveticaను ప్రయత్నిస్తుంది. రెండూ లేకపోతే ఏదైనా సాధారణ sans-serif fontను ఉపయోగిస్తుంది.

Generic font families

  • serif – అక్షరాల చివర్లలో చిన్న అలంకరణలు ఉండే font style.
  • sans-serif – సరళమైన, ఆధునికంగా కనిపించే font style.
  • monospace – ప్రతి అక్షరానికి సమాన వెడల్పు ఉండే font style.
  • cursive – చేతిరాతను పోలి ఉండే font style.
  • fantasy – అలంకారమైన display font style.

సాధారణ website text కోసం sans-serif లేదా serif కుటుంబాలు ఎక్కువగా ఉపయోగిస్తారు. Code లేదా programming text కోసం monospace ఉపయోగకరంగా ఉంటుంది.

Simple Explanation

font-familyతో text ఏ fontలో కనిపించాలో చెబుతాము. ఒకే fontపై ఆధారపడకుండా fallback fonts కూడా ఇవ్వాలి.

ఉదాహరణకు font-family: Georgia, "Times New Roman", serif; అంటే browser ముందుగా Georgiaను ఉపయోగిస్తుంది. అది అందుబాటులో లేకపోతే Times New Romanను ఉపయోగిస్తుంది. అవి రెండూ లేకపోతే serif familyలోని మరో fontను ఎంచుకుంటుంది.

Web-safe fonts ఉపయోగిస్తే visitor computerలో ఆ font లేకపోవడం వల్ల layout లేదా text appearance పూర్తిగా మారే అవకాశం తగ్గుతుంది.

Real-Life Example

ఒక పుస్తకానికి serif font ఉపయోగిస్తే అది సంప్రదాయంగా, చదవడానికి అనుకూలంగా కనిపించవచ్చు. ఒక technology websiteకి sans-serif font ఉపయోగిస్తే అది modernగా కనిపిస్తుంది. Programming code చూపించే editorలో monospace font ఉపయోగిస్తే ప్రతి అక్షరం సమాన వెడల్పుతో కనిపిస్తుంది.

Code Examples

Different Font Families with Fallback Fonts

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Font Families</title>
  <style>
    body {
      font-family: Arial, Helvetica, sans-serif;
      line-height: 1.6;
      color: #222222;
    }

    h1 {
      font-family: Georgia, "Times New Roman", serif;
      color: #17365d;
    }

    .code-text {
      font-family: "Courier New", Courier, monospace;
      background-color: #f2f2f2;
      padding: 8px;
    }
  </style>
</head>
<body>
  <h1>Readable Web Fonts</h1>
  <p>This paragraph uses a sans-serif font.</p>
  <p class="code-text">font-family: monospace;</p>
</body>
</html>

ఈ ఉదాహరణలో body text కోసం Arial fallback listను, heading కోసం Georgia fallback listను, code-like text కోసం Courier New మరియు monospace familyను ఉపయోగించాము. ప్రతి font అందుబాటులో లేకపోతే browser listలోని తదుపరి fontను ఎంచుకుంటుంది.

The page displays a blue heading in a serif-style font, a normal paragraph in a sans-serif font, and a gray code-like paragraph in a monospace font.

Line-by-Line Explanation

<style>
ఇక్కడి నుంచి pageకి సంబంధించిన internal CSS ప్రారంభమవుతుంది.
body {
body selector మొత్తం page contentను select చేస్తుంది.
font-family: Arial, Helvetica, sans-serif;
మొత్తం page text కోసం browser ముందుగా Arialను ప్రయత్నిస్తుంది. అది లేకపోతే Helvetica, చివరగా sans-serif generic family ఉపయోగించబడుతుంది.
line-height: 1.6;
Paragraph lines మధ్య vertical spaceను ఇస్తుంది. ఇది గత lessonలో నేర్చుకున్న line-height propertyకి ఉదాహరణ.
h1 {
ఈ selector అన్ని h1 headingsను select చేస్తుంది.
font-family: Georgia, “Times New Roman”, serif;
Heading కోసం Georgiaను మొదటి ఎంపికగా ఉంచాము. Georgia లేకపోతే Times New Roman, తరువాత serif family ఉపయోగించబడుతుంది.
.code-text {
code-text class ఉన్న elementను select చేస్తుంది.
font-family: “Courier New”, Courier, monospace;
Code-like text కోసం Courier Newను ఉపయోగిస్తుంది. అది లేకపోతే Courier లేదా monospace generic family ఉపయోగించబడుతుంది.
background-color: #f2f2f2;
Code text వెనుక లేత బూడిద background ఇస్తుంది. ఇది font family ఉదాహరణను సులభంగా గుర్తించడానికి సహాయపడుతుంది.
<h1>Readable Web Fonts</h1>
ఈ headingకు h1 selector వర్తిస్తుంది కాబట్టి ఇది Georgia వంటి serif fontలో కనిపిస్తుంది.
<p>This paragraph uses a sans-serif font.</p>
ఈ paragraphకి ప్రత్యేక class లేదు. అందువల్ల bodyలో ఇచ్చిన Arial, Helvetica, sans-serif font listను అనుసరిస్తుంది.
<p class=”code-text”>font-family: monospace;</p>
ఈ paragraphకు code-text class ఉంది. అందువల్ల ఇది Courier New లేదా monospace styleలో కనిపిస్తుంది.

Try It

Try this CSS code:

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Try Font Families</title>
  <style>
    body {
      font-family: Arial, sans-serif;
    }

    h1 {
      font-family: Georgia, serif;
    }

    p {
      font-family: "Courier New", monospace;
    }
  </style>
</head>
<body>
  <h1>My Font Practice</h1>
  <p>Change the font-family values and run the page again.</p>
</body>
</html>

Try It Yourself »

Practice

Practice: పై practice_codeలో h1 headingను monospace fontలో మరియు paragraphను Georgia వంటి serif fontలో చూపించండి. ప్రతి fontకు కనీసం ఒక fallback family ఇవ్వండి.

Hint: h1 కోసం “Courier New”, Courier, monospace మరియు p కోసం Georgia, “Times New Roman”, serif వంటి font lists ఉపయోగించండి.

Common Mistakes

font-family property పేరు తప్పుగా రాయడం, ఉదాహరణకు font-famly.
సరైన property పేరు font-family. Hyphen మరియు spellingను జాగ్రత్తగా రాయండి.
ఒకే font పేరు ఇచ్చి fallback font ఇవ్వకపోవడం.
మొదటి font తర్వాత commaతో fallback fonts మరియు చివరలో generic family ఇవ్వండి. ఉదాహరణ: font-family: Arial, Helvetica, sans-serif;.
రెండు పదాల font nameను quotes లేకుండా రాయడం, ఉదాహరణకు Times New Roman.
రెండు లేదా అంతకంటే ఎక్కువ పదాలు ఉన్న font namesను quotesలో రాయండి: "Times New Roman".
Generic familyని quotesలో రాయడం, ఉదాహరణకు "sans-serif".
serif, sans-serif, monospace వంటి generic family namesను సాధారణంగా quotes లేకుండా రాయండి.
font family పేరును selectorగా రాయడం.
Fontను మార్చడానికి selectorలో font-family declaration ఉపయోగించాలి: p { font-family: Georgia, serif; }.

Interview Questions

CSSలో font-family property ఎందుకు ఉపయోగిస్తారు?

Answer: Elementలోని text ఏ fontలో కనిపించాలో నిర్ణయించడానికి font-family property ఉపయోగిస్తాము.

Web-safe font అంటే ఏమిటి?

Answer: చాలా computers మరియు operating systemsలో సాధారణంగా అందుబాటులో ఉండే fontను web-safe font అంటారు. ఉదాహరణకు Arial, Georgia మరియు Courier New.

Font fallback list ఎందుకు ఇస్తారు?

Answer: మొదటి font visitor computerలో అందుబాటులో లేకపోతే browser తదుపరి fontను ఉపయోగించడానికి fallback list ఇస్తారు.

CSSలో generic font family అంటే ఏమిటి?

Answer: ఒక నిర్దిష్ట font పేరు కాకుండా font style కుటుంబాన్ని సూచించేది generic font family. ఉదాహరణలు serif, sans-serif మరియు monospace.

Exam Questions

Arialను మొదటి ఎంపికగా, sans-serifను fallbackగా ఉపయోగించే CSS declaration రాయండి.

Answer:

font-family: Arial, sans-serif;

Georgia font అందుబాటులో లేకపోతే Times New Romanను ఉపయోగించే font list రాయండి.

Answer:

font-family: Georgia, "Times New Roman", serif;

Programming code textకు సాధారణంగా ఉపయోగించే generic font family ఏది?

Answer:

monospace generic family.

రెండు పదాల font nameను CSSలో ఎలా రాస్తారు?

Answer:

దాన్ని quotesలో రాస్తారు. ఉదాహరణ: font-family: "Times New Roman", serif;

Quick Revision

  • font-family text యొక్క font styleను నిర్ణయిస్తుంది.
  • Web-safe fonts సాధారణంగా చాలా devicesలో అందుబాటులో ఉంటాయి.
  • Fallback fontsను commaతో వేరు చేసి listగా రాయాలి.
  • రెండు పదాల font namesను quotesలో రాయాలి.
  • చివరలో serif, sans-serif లేదా monospace వంటి generic family ఇవ్వడం మంచిది.
  • Heading, paragraph మరియు code textకు వేర్వేరు font families ఇవ్వవచ్చు.

Test Your Knowledge

Take a short quiz based on this lesson.

10 Questions • Results
Scroll to Top