CSS specificity
Në shqip: Specifiteti në CSS
ShpjegimiSQ
Kur dy rregulla CSS i japin të njëjtit element stile të ndryshme, fiton ai më specifik: një #id mund më shumë se një .klasë, dhe një .klasë më shumë se një tag. Nëse janë njësoj, fiton ai që shkruhet më poshtë. !important i kapërcen të gjitha — por përdore rrallë.
EnglishEN
When two CSS rules give the same element different styles, the more specific one wins: an #id beats a .class, and a .class beats a tag. If they're equal, the one written later wins. !important overrides everything — but use it rarely.
Si ta mendosh
Si urdhrat në shtëpi: „të gjithë fëmijët në shtrat në 10“ vlen, por „Ardi mund të rrijë deri në 11 sonte“ është më specifik — dhe fiton.
Lexoje në anglisht
Like house rules: “all kids in bed at 10” applies, but “Ardi can stay up till 11 tonight” is more specific — and wins.
Shembull kodicss
p { color: black; } /* më i dobëti */
.shenim { color: blue; } /* fiton mbi p */
#kryesor { color: red; } /* fiton mbi .shenim */