Cascading Style Sheets (CSS) – Grade 13 A/L ICT Notes 10.5

© 2026 schoolict.net (Ruwan Mangala Suraweera)

10.5 Cascading Style Sheets (CSS)Cascading Style Sheets (CSS)

Grade 13 A/L ICT · Lesson 1013 ශ්‍රේණිය A/L ICT · පාඩම 10

Prints all tabs in the language you are reading. Use “Save as PDF” in the print window to keep a copy.ඔබ කියවන භාෂාවෙන් සියලු tabs මුද්‍රණය වේ. පිටපතක් තියාගන්න print window එකේ “Save as PDF” තෝරන්න.
🎬Video coming soon in this language. Switch language to watch the other video.මේ භාෂාවෙන් වීඩියෝව ඉක්මනින් එනවා. අනෙක් වීඩියෝව බලන්න භාෂාව මාරු කරන්න.

In this videoමේ වීඩියෝවේ

  • CSS separates appearance from content.CSS පෙනුම අන්තර්ගතයෙන් වෙන් කරයි.
  • A rule is selector { property: value; }.නීතිය = selector { property: value; }.
  • Element, class, id and group selectors.selectors හතර.
  • Inline, internal and external CSS.inline, අභ්‍යන්තර, බාහිර.
  • Inline > id > class > element.inline > id > class > element.
CSSRuleSelectorDeclarationPropertyClass selectorId selector

Notesසටහන්

Syllabus 10.5. A style sheet controls how a page looks, keeping content (HTML) separate from appearance (CSS). A CSS rule has a selector and declarations property: value;. Selectors pick elements, an id, a class or a group. CSS can be inserted inline, internally in

CSS demo

Plain paragraph

Class tip

Id beats class

Inline beats all

">
SelectorSelectorExampleඋදාහරණයSelectsතෝරන්නේ
Elementමූලද්‍රව්‍යයp { … }p { … }Every p elementසියලු p
ClassClass.tip { … }.tip { … }Elements with class="tip" (many allowed)class="tip" සහිත (බොහෝ විය හැක)
IdId#note { … }#note { … }The one element with id="note"id="note" සහිත එකම මූලද්‍රව්‍යය
GroupGrouph1, h2 { … }h1, h2 { … }Several selectors share one ruleselectors කිහිපයකට එක් නීතියක්
Which style wins? (highest first)inlinestyle="…"#id.classelementpSame priority: the rule written later wins. External, internal and inline styles all join the cascade.
Priority when rules conflictනීති ගැටෙන විට ප්‍රමුඛතාව
🧮 Worked exampleවිසඳූ උදාහරණය What colour is each paragraph in the demo?demo එකේ එක් එක් ඡේදයේ වර්ණය කුමක්ද?
Plain paragraph: black (element rule). “Class tip”: green (class beats element). “Id beats class”: red – it has both class="tip" and id="note", and the id selector is stronger. “Inline beats all”: purple – an inline style attribute wins over the internal style sheet. The headings are navy from the group selector h1, h2.සාමාන්‍ය ඡේදය: කළු. “Class tip”: කොළ. “Id beats class”: රතු – id selector ප්‍රබලයි. “Inline beats all”: දම් – inline style ජය ගනී. ශීර්ෂ group selector මගින් navy.

3. External style sheet3. බාහිර style sheet

🌐 HTML: Linking an external style sheetබාහිර style sheet සම්බන්ධ කිරීම

>
>
  >External CSS>
   rel="stylesheet" href="style.css">
>
>
  >Welcome>
  >This page is styled by style.css.>
>
>

▶ Result in the browserබ්‍රව්සරයේ ප්‍රතිඵලය

📄 style.css
/* style.css – one file styles every page */
body { background-color: #fffbe6; font-family: Verdana, sans-serif; }
h1 { color: #b45309; font-size: 28px; }
p { font-size: 16px; line-height: 1.5; }
a:link { color: blue; }
a:visited { color: purple; }
table { border-collapse: collapse; }
th { background-color: #0b1d3f; color: white; }
Methodක්‍රමයHowකෙසේදBest useවඩාත් සුදුසු
InlineInlinestyle="color: purple;"style="color: purple;"One element onlyඑක් මූලද්‍රව්‍යයක්
Internalඅභ්‍යන්තර
© 2026 schoolict.net (Ruwan Mangala Suraweera). All rights reserved.සියලු හිමිකම් ඇවිරිණි.
🔴 Lesson List
SIDE BUTTON ON
⬆
×

👋 Welcome Back!

🚀
Ready to Learn?Pick up where you left off.
🔑
Forgot Password?Click the link below to reset.
📢
New FeaturesCheck out the new AI Voice tool.

Sign In

👤
🔒
or continue with
Google Facebook

Already have an account? Register Now