HTML
HTML
> A semantic element clearly describes its meaning to both the browser and the
developer.
- Examples of non-semantic elements: <div> and <span> - Tells nothing about its
content.
- For example, a <p> tag indicates that the enclosed text is a paragraph. This is both
semantic and presentational because people know what paragraphs are, and
browsers know how to display them.
- On the flip side of this equation, tags such as <b> and <i> are not semantic. They
define only how the text should look (bold or italic), and don't provide any additional
meaning to the markup.
> References:
Line-hieght property gives the paragraph ability to set space between the
lines/
By default the line hieght is 1 and we set to 1.5 then the line hieght would be
1.5 time the font-size.
Text-alegn: center will center the text of the viewport.
Descendent selector
Footer inside p footer p{ it select all the elements that are inside the footer
elements.
}
Id and classes : - in id we can use each id name only once , it means we cant
repeat id names and for that we use classes.
Pseudo class
We write a pseudo class by writing a colon and the list of options appeared and
in decleation block we write the code.
Li:first-child, li:last-child and we can tearget the specific child li:nth-child(2){}
Li:nth-child(odd){
}
a:link {
color: #1098ad;
}
This will target all the anchor elements that have an href attribute and the with
not it will not target.
a:active {
background-color: black;
font-style: italic;
}
This div has width of 200px and we give a 10px border then it add to
this div what will happen is the 10px add to the div give a total width
of 220px.
Style properties
Clip-path property checkout this property from
https://bennettfeely.com/clippy/
Img properties:
In img properties we have alt attribites is to describe the image for SEO but also in the case
the image fails to load and then on the website instead of image showing this text appears
that we put in alt attribute.
Inline and block level elements :-
Block elements means it occupy all space which he gets in his
width and the next element comes in a new line. Or in the
other side they cannot be side by side with one another.
Elements occupy 100% width of parent element width no matter the content.
A block-level element always takes up the full width available (stretches out
to the left and right as far as it can).
You can define the hieght and width in block lvl elements.
It does not let anyone else come after it in the same line,
Block lvl elements are <address>
<article> <aside> <blockquote> <canvas> <dd> <div> <dl> <dt>
<fieldset> <figcaption> <figure> <footer> <form> <h1>-<h6 >
<header> <hr> <li> <main> <nav> <noscript> <ol> <p> <pre>
<section> <table> <tfoot> <ul> <video>
Inline Elements
An inline element only takes up as much width as necessary.
In inline elements you cannt define the hieght and width. And it is because it
automatically adjust its height and width according to the content.
<a> <abbr> <acronym> <b> <bdo> <big> <br> <button> <cite> <code>
<dfn>
<em> <i> <img> <input> <kbd> <label> <map> <object> <output> <q>
<samp>
<script> <select> <small> <span> <strong> <sub> <sup> <textarea>
<time>
<tt> <var>
Display : inline-block
Like inline element it does not start on a new line.
Apni normal position ke relative voh move kareyga and leave a gap at its
position.
Position Absolute
LAYOUTS
1. FLOATS
Collapsing elements when there is one parent
element and inside of those there are two div
element and we specified float left and other
to float right the parent hieght will
collapsed.
It is same as absolute positioning as the
element is not on the page.
Second technique
The second technique we use is to add class of
clearfix to the parent element whose hieght has
collapsed and then select the class like this :
.clearfix::after {
content: "";
clear: both;
display: block;
}
Position center
.text-box {
position: absolute;
top: 50%;
left: 50%;
/* -50% on x-axis will shifted half of the width to the left side and
same on the y axis i mean height , it will be shifted 50% of the height
to the top */
transform: translate(-50%, -50%);
}
Animations
There are generally two types of
animation in css
1. Transition property
2. Keyframes
100% {
opacity: 1;
transform: translate(0);
}
}
CSS Syntax
box-shadow: none|h-offset v-offset blur spread color |inset|
initial|inherit;
Property Values
Value Description
v-offset Required. The vertical offset of the shadow. A positive value puts the shadow below the box, a n
value puts the shadow above the box
blur Optional. The blur radius. The higher the number, the more blurred the shadow will be
spread Optional. The spread radius. A positive value increases the size of the shadow, a negative value
decreases the size of the shadow
color Optional. The color of the shadow. The default value is the text color. Look at CSS Color Values fo
complete list of possible color values.
Fluid Layouts
Media queries
Responsive images
Correct units
Desktop-First vs mobile-first
3. Web Performance
Less http requests
Less code
Compress code
Use a css preprocessor like sass
Less images
Compress Images
1.Load HTML
Browser actually starts to load
the intial html file.
2.Parse HTML
It then takes the loaded HTML code and parses it which
basically means that it decodes the code line by line.
Form this process the browser builds so called DOM which
basically describes the entire web document like a family
tree with parents, children and sibling elements.
So this DOM is where the entire decoded html code is
stored.
3.Load CSS
Now, as the browser parses the html, it also finds the style sheets
included in the html head, and it starts loading them as well. And
just like the html, CSS is also parsed, but the parsing of CSS is a
bit more complex. And that's why we'll talk about that in great
detail
4.Parse CSS
For now, let me just tell you that during the CSS parsing phase,
there are two main steps.
And that's why these percentages, and other relative units, can only
be calculated on the user's device in the parsing phase.
Summary
What is sass ?
2. Nesting
Another Example
@include style-link-text($color-text-dark);
@include style-link-text($color-text-light);
4. Function
In sass function works like this
Nav{
Margin: divide(60,2) * 1px ; //30px
Backgorund-color: $color-primary;
}
Implementing 7-1
architecture with sass
7-1 pattern where we create 7 folders and
one main SASS file to import all the
files that are in these folders.
So, Let's start by creating the base folderwhich is where we're going to
put our basic project definitions.
Responsive Design Principles
and layout types
Use @if and @else to Add Logic To Your Styles
@mixin border-stroke($val){
@if $val == light{
border: 1px solid black;
}
@else if $val == medium{
border: 3px solid black;
}
@else if $val == heavy{
border: 6px solid black;
}
@else {
border: none;
}
}
#box {
width: 150px;
height: 150px;
background-color: red;
@include border-stroke(medium);
}
Not pseudo selector
And we use like this
&:not(:last-child){ } without the not it
would simply select the last child and
what not does it select everything except
the last child.
Linear gradient: it goes from one side to
other one while the radial gradient start
in the middle of an element and goes from
there in all the outside directions
bascially.
container.
Strech all the elements will automatically stretch as tall as the tallest element in align-items: flex-
start
Align-items center will center the element in the container vertically and is used for all the items.
Justify content space-between will distribute the space between the elements.
Order property: by default all the order of the elements in the flex container are zero
And the one with the less order will appear in first -1, 0, 1 .
Gap property will give the gap between the flex items in the flex container.
Flex property is a shorthand for flex grow , flex basis and felx shrink.
Default .el{
Flex-grow: 0;
CSS GRID
Grid-template colomns: 250px 150px;
Fr unit So using the fr unit here instead of pixels
will allow us to very easily create flexible columns,
and flexible rows.
It helps to fill the remaining space. Same width to
all column set to 1fr.
Max-content
It makes the column as wide as
it has to be to fit the content .
Min-content
It fits the content without
overflowing
Min-max function
It ensures that the property
stays between 150px and min-
content or whatever we define.
Auto-fill
It make column automaticalyy
to fill the entire width;
Max-width set on a cantainer :- if container has not
enogh space then it will occupy 100vh
Stroke css changes the color of svg element.
By fill we can fill the coloe inside the svg element.
Adding shadow to the box :-
Box-shadow: first one is horizontal offset between the
box and the shadow, second value if for vertical
direction, third value is for blur, value number four is
optional(it allows us to do bascially scale the shadow
up, last one is color of the shadow)
Text-shadow: this one doesn’t have fourth value.
!important: - Margin 0 auto works when we define the
width of a element.
VW unit I too struggled to understand why we are defining the height of a row,
with a unit that suggests width. So I looked into it:
It's important to look at it this way; we are not defining the width of the row here,
using the VW unit. We are defining the HEIGHT. Strange? I know! but it makes sense.
How? well, 40vw used with grid-template-rows: says that the HEIGHT of that
particular row will ALWAYS be 40%(40vw) of the viewport width(width of your
screen). So for example, if you are on a device that has a viewport width of 400px,
the height of the row specified as 40vw, will have a height of 160px (400 * 0.4 =
160).
1. He defined the height of the row using the vw unit.
direction.
3. if we decrease the viewport width in the horizontal direction,, it decrease the row
height.
4. if we have used the vh unit then it wouldn't be possible to reduce the row height
while decreasing the viewport width.
BEM NOTATIONS
BLOCK AND MODIFIER