How HTML renders in our pages
HTML types of Element
primarily
CSS Selectors:-
CSS Inheritance
It occurs when an inheritance CSS property (i.e color) is not set directly on an element, the parent chain is traversed until a value for that property is found.
<div class="body"> <p>This is a Paragraph, but it will have the blue color due to inheritance</p> </div> <style> .body{ color: blue; } </style>
case 2
<div class="body"> <p>This is a Paragraph, but it will have the red color due to direct Specification</p> </div> <style> p { color: red; } .body{ color: blue; } </style>
case 3
<div class="body"> <p>This is a Paragraph, but it will have the blue color due to strong Specification</p> </div> <style> p { color: red; } .body p{ color: blue; } </style>
What is CSS Specificity
NOTE:- Inline Css are more specificity and !import has even more specificity
Css Specificity Calculator
Em & Rem
EM:- relative to its parent font-side
<html> <div> <p></p> </div> </html> <style> html { font-size: 16px; } div { font-size: 2em; //16px * 2 = 32px; } p { font-size: 2em; // 32px * 2 = 64px } </style>
REM:- relative to Root font-side
<html> <div> <p></p> </div> </html> <style> html { font-size: 16px; } div { font-size: 2rem; //16px * 2 = 32px; } p { font-size: 2rem; // 16px * 2 = 32px } </style>
%:- % calculation
<html> <div> <p></p> </div> </html> <style> html { font-size: 16px; } div { font-size: 120%; //1.2*16 = 19.2px; } p { font-size: 120%; // 1.2 * 19.2 = 23.04px } </style>
CSS Combinators
1.Descendent Selector (ul li a)
<ul> <li><a href='#'></a></li> </ul>
2.Child Combinators (direct Descendant) (div.text > p)
<div> <div class="text"> <P>Here the CSS will apply<P> </div> <div> <p>No CSS will apply</p> </div> </div>
3.Adjacent Sibling Combinator (h1 + p)
Note:-
4.General Sibling Combinator (p ~ code)
Note:-
Block Element Modifier Architechure(BEM)
Other Methodologies
Block
Element (part of block)
Modifier
.block__element--modifier Syntax
<form class=form> <input class='form__input'/> <input class="form__input form__input--disabled"/> <button class="form__button form__button--large"/> </form>
Box Model:- (W.I.P)
We need to add more information from the Detail information
NOTE:-
There will be a separate article on the grid layout vs Flex layout.
The above is the detailed content of CSS In Details. For more information, please follow other related articles on the PHP Chinese website!