Line Height

Line Height అంటే ఏమిటి?

CSSలో line-height property ఒకే paragraphలోని వరుసల మధ్య vertical spaceను నియంత్రిస్తుంది. Text lines దగ్గరగా లేదా దూరంగా కనిపించాలంటే ఈ propertyని ఉపయోగిస్తాం.

ఎందుకు ఉపయోగిస్తాం?

Line height సరైనంగా ఉంటే paragraph చదవడానికి సులభంగా ఉంటుంది. చాలా తక్కువ line height ఉంటే lines ఒకదానితో ఒకటి కలిసినట్లు కనిపిస్తాయి. చాలా ఎక్కువగా ఉంటే paragraphలో అనవసరమైన ఖాళీ కనిపిస్తుంది.

Syntax

p {
  line-height: 1.6;
}

1.6 అనేది సాధారణంగా font sizeకి multiplierగా పనిచేస్తుంది. ఉదాహరణకు font size 16px అయితే line height సుమారు 25.6px అవుతుంది.

Line-height విలువలు

  • Unitless value: 1.5 వంటి విలువ. ఇది flexible మరియు సాధారణంగా మంచి ఎంపిక.
  • Length value: 24px వంటి నిర్దిష్ట vertical space.
  • Percentage: 150% వంటి విలువ. ఇది font size ఆధారంగా line heightను లెక్కిస్తుంది.

ఎలా apply చేయాలి?

ముందుగా HTMLలో paragraph లేదా headingను రాయాలి. తర్వాత CSS selectorతో ఆ elementను select చేసి line-height property ఇవ్వాలి. Browser ప్రతి text line మధ్య vertical spacingను మార్చుతుంది.

Code Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Line Height Example</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 30px;
    }

    .reading-text {
      font-size: 18px;
      line-height: 1.7;
      max-width: 600px;
    }
  </style>
</head>
<body>
  <h1>Comfortable Reading</h1>
  <p class="reading-text">Good line height makes a paragraph easier to read. It gives each line enough vertical space and prevents the text from looking crowded.</p>
</body>
</html>

ఈ exampleలో .reading-text paragraphకు line-height: 1.7; ఇవ్వడం వల్ల ప్రతి line మధ్య చదవడానికి సరిపడే vertical space కనిపిస్తుంది.

Simple Explanation

line-height అంటే textలోని ఒక line నుంచి తరువాతి line వరకు ఉండే vertical distance. Paragraphలో lines చాలా దగ్గరగా కనిపిస్తే valueను పెంచండి. Lines చాలా దూరంగా కనిపిస్తే valueను తగ్గించండి.

ఉదాహరణకు line-height: 1.5; అంటే element యొక్క font sizeకి 1.5 రెట్లు line height ఉంటుంది. Paragraph text కోసం unitless values ఉపయోగించడం సులభం మరియు flexible.

Real-Life Example

ఒక పుస్తకంలో lines పూర్తిగా దగ్గరగా ముద్రిస్తే చదవడం కష్టం అవుతుంది. ప్రతి line మధ్య కొంత ఖాళీ ఉంటే కళ్లకు lineను follow చేయడం సులభం. వెబ్ పేజీలో paragraphలకు line-height అదే విధంగా readabilityని మెరుగుపరుస్తుంది.

Code Examples

Paragraph Readability with line-height

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Line Height Example</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 30px;
    }

    .reading-text {
      font-size: 18px;
      line-height: 1.7;
      max-width: 600px;
    }
  </style>
</head>
<body>
  <h1>Comfortable Reading</h1>
  <p class="reading-text">Good line height makes a paragraph easier to read. It gives each line enough vertical space and prevents the text from looking crowded.</p>
</body>
</html>

.reading-text selector paragraphను select చేస్తుంది. font-size: 18px; text sizeను నిర్ణయిస్తుంది. line-height: 1.7; ప్రతి text line మధ్య సరైన vertical space ఇస్తుంది. max-width paragraph చాలా వెడల్పుగా మారకుండా readabilityకి సహాయపడుతుంది.

The browser displays a heading and a readable paragraph. The paragraph lines have comfortable vertical spacing because the line-height is 1.7.

Line-by-Line Explanation

.reading-text {
ఈ selector class=”reading-text” ఉన్న paragraphను select చేస్తుంది. అందువల్ల ఈ rules ఆ paragraphకు మాత్రమే వర్తిస్తాయి.
font-size: 18px;
Paragraph text sizeను 18 pixelsగా ఉంచుతుంది. Line height లెక్కించేటప్పుడు ఈ font size ఆధారంగా తీసుకోబడుతుంది.
line-height: 1.7;
ప్రతి text line మధ్య vertical distanceను font sizeకి 1.7 రెట్లు చేస్తుంది. అందువల్ల paragraph crowdedగా కనిపించదు.
max-width: 600px;
Paragraph వెడల్పును గరిష్ఠంగా 600 pixelsగా ఉంచుతుంది. చిన్న text lines మరియు సరైన line height కలిసి చదవడాన్ని సులభం చేస్తాయి.
<p class=”reading-text”>Good line height makes a paragraph easier to read. It gives each line enough vertical space and prevents the text from looking crowded.</p>
ఈ paragraphకు reading-text class ఉంది. అందువల్ల పై CSS rules ఈ visible textకు apply అవుతాయి.

Try It

Try this CSS code:

Example

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

    p {
      font-size: 18px;
      line-height: 1.5;
      max-width: 550px;
    }
  </style>
</head>
<body>
  <h1>Read This Paragraph</h1>
  <p>Line height controls the vertical space between lines of text. Change the CSS value and observe how the paragraph changes.</p>
</body>
</html>

Try It Yourself »

Practice

Practice: పై practice codeలో paragraph lines చాలా దగ్గరగా కనిపిస్తున్నాయి. .article selectorలో line-height విలువను 1.8గా మార్చి browserలో ఫలితాన్ని గమనించండి.

Hint: line-height: 1.2; ను line-height: 1.8;గా మార్చండి. Value పెరిగితే lines మధ్య vertical space పెరుగుతుంది.

Common Mistakes

Propertyను lineheightగా రాయడం.
సరైన CSS property పేరు line-height. రెండు పదాల మధ్య hyphen తప్పనిసరిగా ఉండాలి.
line-heightకు value ఇవ్వకుండా property మాత్రమే రాయడం.
ఉదాహరణకు line-height: 1.6; లేదా line-height: 24px; వంటి value ఇవ్వాలి.
చాలా చిన్న value పెట్టి text linesను ఒకదానిపై మరొకటి దగ్గరగా చేయడం.
Paragraph readability కోసం సాధారణంగా 1.4 నుంచి 1.8 మధ్య valueలను పరీక్షించి సరైనదాన్ని ఎంచుకోండి.
ఒకే paragraphకు అవసరమైన line height బదులుగా ప్రతి lineకు వేర్వేరు spacing ఇవ్వాలని ప్రయత్నించడం.
Paragraphను select చేసి దానికి ఒక సరైన line-height value ఇవ్వండి. Browser ఆ paragraphలోని అన్ని linesకు spacingను apply చేస్తుంది.

Interview Questions

CSSలో line-height property ఏమి చేస్తుంది?

Answer: ఇది textలోని వరుసల మధ్య vertical spaceను నియంత్రిస్తుంది. Paragraph readabilityని మెరుగుపరచడానికి ఉపయోగిస్తాం.

line-height: 1.5; అంటే ఏమిటి?

Answer: ఇది సాధారణంగా element యొక్క font sizeకి 1.5 రెట్లు line heightను సెట్ చేస్తుంది. ఉదాహరణకు font size 16px అయితే line height సుమారు 24px అవుతుంది.

Paragraphకు line-height ఎందుకు ఉపయోగిస్తారు?

Answer: Lines చాలా దగ్గరగా లేదా చాలా దూరంగా కనిపించకుండా చేసి textను సులభంగా చదవడానికి ఉపయోగిస్తారు.

Exam Questions

ఖాళీని పూరించండి: Text lines మధ్య vertical spaceను నియంత్రించే CSS property ________.

Answer:

line-height

క్రింది declarationలో line height value ఏది? p { line-height: 1.6; }

Answer:

1.6

line-height valueను పెంచితే paragraphలో ఏమి మారుతుంది?

Answer:

Text lines మధ్య vertical space పెరుగుతుంది.

Unitless line-height valueకు ఒక ఉదాహరణ ఇవ్వండి.

Answer:

line-height: 1.5;

Quick Revision

  • line-height text lines మధ్య vertical spaceను నియంత్రిస్తుంది.
  • Paragraph readability కోసం line-height చాలా ముఖ్యమైనది.
  • Unitless valuesగా 1.5 లేదా 1.7 వంటి values ఉపయోగించవచ్చు.
  • Line height value పెరిగితే lines మధ్య ఖాళీ పెరుగుతుంది.
  • సరైన property పేరు line-height; hyphen మర్చిపోవద్దు.

Test Your Knowledge

Take a short quiz based on this lesson.

10 Questions • Results
Scroll to Top