What Is CSS?

What Is CSS?

CSS అంటే Cascading Style Sheets. HTMLతో తయారైన వెబ్ పేజీకి రంగులు, fonts, sizes, spacing మరియు layout వంటి visual styles ఇవ్వడానికి CSS ఉపయోగిస్తాము.

HTML పేజీలోని content మరియు structure ను అందిస్తుంది. CSS ఆ content ఎలా కనిపించాలో నిర్ణయిస్తుంది. ఉదాహరణకు, HTMLలో ఉన్న headingను blue colorలో చూపించడం, paragraph text size మార్చడం లేదా page background color ఇవ్వడం CSS ద్వారా చేయవచ్చు.

CSS ఎలా పనిచేస్తుంది?

Browser ముందుగా HTML elementsను చదువుతుంది. తరువాత CSS rulesను చదివి, ఏ elementకు ఏ style వర్తించాలో నిర్ణయిస్తుంది. CSSలో సాధారణంగా ఒక selector, ఒకటి లేదా ఎక్కువ declarations ఉంటాయి.

ఒక declarationలో property మరియు దాని value ఉంటాయి. ఉదాహరణకు, color: navy;లో color property, navy value.

CSSను HTMLతో కలపడం

ఈ lessonలో CSSను HTML documentలోని <style> elementలో రాస్తాము. <style> element సాధారణంగా <head>లో ఉంటుంది. Browser ఆ CSSను ఉపయోగించి <body>లోని contentను style చేస్తుంది.

చిన్న ఉదాహరణ

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My First CSS Page</title>
  <style>
    body {
      background-color: #f2f7ff;
      font-family: Arial, sans-serif;
    }

    h1 {
      color: navy;
      font-size: 32px;
    }

    p {
      color: #333333;
    }
  </style>
</head>
<body>
  <h1>Welcome to CSS</h1>
  <p>CSS changes the appearance of HTML content.</p>
</body>
</html>

ఈ codeలో HTML contentను సృష్టిస్తుంది, CSS ఆ content యొక్క appearanceను మార్చుతుంది. Codeను browser-based HTML editorలో paste చేసి run చేస్తే resultను చూడవచ్చు.

Simple Explanation

CSS అనేది వెబ్ పేజీకి design ఇవ్వడానికి ఉపయోగించే language. HTML ఒక ఇంటి గోడలు మరియు గదుల structureలాంటిది. CSS ఆ ఇంటికి paint, furniture arrangement మరియు decoration ఇవ్వడంలాంటిది.

CSSతో HTML contentను తొలగించకుండా దాని రంగు, పరిమాణం మరియు కనిపించే విధానాన్ని మార్చవచ్చు. CSS స్వయంగా కొత్త HTML contentను సృష్టించదు మరియు programming logicను అందించదు.

Real-Life Example

ఒక school notice boardను ఊహించండి. HTMLలో notice heading మరియు message ఉంటాయి. CSS headingకు blue color, పెద్ద size, notice boardకు light background ఇవ్వగలదు. Content అదే ఉన్నా, CSS వల్ల అది చక్కగా మరియు చదవడానికి సులభంగా కనిపిస్తుంది.

Code Examples

My First CSS Page

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My First CSS Page</title>
  <style>
    body {
      background-color: #f2f7ff;
      font-family: Arial, sans-serif;
    }

    h1 {
      color: navy;
      font-size: 32px;
    }

    p {
      color: #333333;
    }
  </style>
</head>
<body>
  <h1>Welcome to CSS</h1>
  <p>CSS changes the appearance of HTML content.</p>
</body>
</html>

ఈ complete HTML documentలో <style> element ద్వారా CSSను రాశాము. body selector page background మరియు fontను style చేస్తుంది. h1 selector heading color మరియు sizeను మార్చుతుంది. p selector paragraph text colorను మార్చుతుంది.

The browser shows a light blue page background, a navy 32-pixel heading saying Welcome to CSS, and a dark gray paragraph below it.

Line-by-Line Explanation

<style>
ఈ elementలో CSS rules రాస్తాము. Browserలోని HTML contentకు ఈ rules వర్తిస్తాయి.
body {
ఇది body selector. వెబ్ పేజీలోని ప్రధాన visible భాగాన్ని select చేస్తుంది.
background-color: #f2f7ff;
body యొక్క background colorను light blue shadeగా మార్చుతుంది. ప్రతి CSS declaration చివర semicolon వాడటం మంచి పద్ధతి.
font-family: Arial, sans-serif;
పేజీలోని text కోసం Arial fontను ఉపయోగించమని browserకు చెబుతుంది. Arial అందుబాటులో లేకపోతే sans-serif font ఉపయోగించబడుతుంది.
}
body selectorకు సంబంధించిన CSS rule ఇక్కడ ముగుస్తుంది.
h1 {
ఇది h1 selector. HTMLలోని <h1> headingను select చేస్తుంది.
color: navy;
heading text colorను navyగా మార్చుతుంది.
font-size: 32px;
heading text sizeను 32 pixelsగా సెట్ చేస్తుంది.
p {
ఇది paragraph selector. HTMLలోని <p> elementకు style ఇవ్వడానికి ఉపయోగించబడుతుంది.
color: #333333;
paragraph textకు dark gray color ఇస్తుంది. Hexadecimal color valueను CSSలో ఉపయోగించవచ్చు.
<h1>Welcome to CSS</h1>
ఇది browserలో ఒక headingను చూపిస్తుంది. పై h1 CSS rule ఈ heading appearanceను మార్చుతుంది.
<p>CSS changes the appearance of HTML content.</p>
ఇది browserలో paragraphను చూపిస్తుంది. పై p CSS rule వల్ల paragraph text dark grayగా కనిపిస్తుంది.

Try It

Try this CSS code:

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>CSS Starter</title>
  <style>
    body {
      background-color: white;
    }

    h1 {
      color: green;
    }

    p {
      color: black;
    }
  </style>
</head>
<body>
  <h1>My CSS Page</h1>
  <p>I am learning CSS.</p>
</body>
</html>

Try It Yourself »

Practice

Practice: practice_codeలో body backgroundను light colorగా మార్చండి. h1కు darkorange color మరియు 32px size ఇవ్వండి. paragraphకు #444444 color మరియు 18px size ఇవ్వండి.

Hint: body, h1 మరియు p selectorsలోని CSS declarationsను మార్చండి. Color value తర్వాత semicolon పెట్టడం మర్చిపోవద్దు.

Common Mistakes

CSS property పేరు తప్పుగా రాయడం, ఉదాహరణకు colour: blue; అని రాయడం.

CSSలో సరైన property పేరు color. కాబట్టి color: blue; అని రాయాలి.

CSS ruleకు curly brackets పెట్టకపోవడం, ఉదాహరణకు h1 color: red; అని రాయడం.

Selector తర్వాత { } brackets ఉపయోగించాలి: h1 { color: red; }.

Property మరియు value మధ్య colon పెట్టకపోవడం, ఉదాహరణకు color red; అని రాయడం.

Property మరియు value మధ్య colon ఉండాలి: color: red;.

<style> elementను మూసివేయకపోవడం లేదా CSSను HTML textగా bodyలో తప్పుగా ఉంచడం.

CSSను <style> మరియు </style> మధ్య రాయండి. సాధారణంగా దీనిని <head>లో ఉంచండి.

Interview Questions

CSS అంటే ఏమిటి?

Answer: CSS అంటే Cascading Style Sheets. HTML content ఎలా కనిపించాలో నిర్ణయించడానికి CSS ఉపయోగిస్తాము.

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

Answer: వెబ్ పేజీకి colors, fonts, sizes, spacing మరియు ఇతర visual styles ఇవ్వడానికి CSS ఉపయోగిస్తాము.

HTML మరియు CSS మధ్య తేడా ఏమిటి?

Answer: HTML పేజీ యొక్క content మరియు structureను అందిస్తుంది. CSS ఆ content యొక్క appearance మరియు presentationను మార్చుతుంది.

HTMLలో CSSను రాయడానికి ఏ element ఉపయోగిస్తాము?

Answer: HTML documentలో CSSను రాయడానికి <style> element ఉపయోగిస్తాము.

Exam Questions

CSS యొక్క full form ఏమిటి?

Answer:

CSS యొక్క full form Cascading Style Sheets.

CSS ఒక HTML headingకు ఏ రెండు styles ఇవ్వగలదు?

Answer:

CSS headingకు color మరియు font-size వంటి styles ఇవ్వగలదు.

CSS programming logicను అందిస్తుందా?

Answer:

లేదు. CSS ప్రధానంగా HTML content యొక్క appearance మరియు presentationను నియంత్రిస్తుంది.

ఈ declarationలో property మరియు value ఏవి: color: navy;?

Answer:

color property, navy value.

Quick Revision

  • CSS అంటే Cascading Style Sheets.
  • HTML structure మరియు contentను అందిస్తుంది; CSS appearanceను మార్చుతుంది.
  • CSSతో colors, fonts, sizes మరియు backgroundsను మార్చవచ్చు.
  • CSS ruleలో selector మరియు declarations ఉంటాయి.
  • Declarationలో property మరియు value ఉంటాయి.
  • <style> elementలో embedded CSSను రాయవచ్చు.
  • CSS స్వయంగా HTML contentను సృష్టించదు మరియు programming logicను అందించదు.

Test Your Knowledge

Take a short quiz based on this lesson.

10 Questions • Results
Scroll to Top