Тёмный

CSS Tutorial in Hindi [Part 47] - Specificity in CSS 

Tech Gun
Подписаться 187 тыс.
Просмотров 19 тыс.
50% 1

In this video i will talk about Specificity in CSS
What is Specificity?
If there are two or more conflicting CSS rules that point to the same element, the browser follows some rules to determine which one is most specific and therefore wins out.
Think of specificity as a score/rank that determines which style declarations are ultimately applied to an element.
The universal selector (*) has low specificity, while ID selectors are highly specific!
Note: Specificity is a common reason why your CSS-rules don't apply to some elements, although you think they should.
Specificity Hierarchy
Every selector has its place in the specificity hierarchy. There are four categories which define the specificity level of a selector:
Inline styles - An inline style is attached directly to the element to be styled.
IDs - An ID is a unique identifier for the page elements, such as #navbar.
Classes, attributes and pseudo-classes - This category includes .classes, [attributes] and pseudo-classes such as :hover, :focus etc.
Elements and pseudo-elements - This category includes element names and pseudo-elements, such as h1, div, :before and :after.
How to Calculate Specificity?
Memorize how to calculate specificity!
Start at 0, add 1000 for style attribute, add 100 for each ID, add 10 for each attribute, class or pseudo-class, add 1 for each element name or pseudo-element.
Specificity Rules
Equal specificity: the latest rule counts - If the same rule is written twice into the external style sheet, then the lower rule in the style sheet is closer to the element to be styled, and therefore will be applied:

Опубликовано:

 

25 авг 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 12   
@komalsethi3295
@komalsethi3295 3 года назад
Thank you sir for specifying the specificity of css rule. As they might looks small but while creating any webpage these points are very useful. 👍
@TechGun
@TechGun 3 года назад
You are most welcome
@NoTimeWaste1
@NoTimeWaste1 Год назад
Thanks bro!! I noticed that if you apply the h1 {background-color: yellow;} inside style block and h1 {background-color: red;} in external style sheet, the style block gets executed instead of external style sheet.
@AmbrishIsCool
@AmbrishIsCool Год назад
Bhai abhi aap kya seekh rahe ho?
@YasirAli-sj5ql
@YasirAli-sj5ql 4 месяца назад
Thanks
@hellfiregaming1827
@hellfiregaming1827 2 года назад
bohot badiya bro, well explained.
@RakibulIslam-hv7if
@RakibulIslam-hv7if 3 года назад
Thank you so much bro
@rohitstrak2199
@rohitstrak2199 2 года назад
mind blowing hai sir jee thanks sir. you are really rightful for appreciate 👍l. 👍l. 👍l. 👍l. 👍
@komalsharma2756
@komalsharma2756 Месяц назад
Thanks sir It was helpful 🙂
@TechGun
@TechGun Месяц назад
Most welcome 😊
@youcube291
@youcube291 Год назад
Super
@srinathmaharana1590
@srinathmaharana1590 3 года назад
Sir please upload full CSS tutorial
Далее
Learn CSS Specificity In 11 Minutes
11:26
Просмотров 96 тыс.
CSS Specificity explained
13:27
Просмотров 130 тыс.
CSS Transition Tutorial in Hindi / Urdu
25:23
Просмотров 143 тыс.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
Просмотров 932 тыс.
CSS Tutorial in Hindi [Part 49] - Flexbox in CSS
29:55
Learn Every CSS Selector In 20 Minutes
19:38
Просмотров 443 тыс.