Prajwal-HTML-CSS-Notes
Prajwal-HTML-CSS-Notes
—-----------------------------------------------------------------------------
Introduction
Web:
Web is a collection of information. i.e in the form of text / web pages / websites.
Webpage:
Website:
Network:
Two or more computers that are connected with one another for the purpose of
Internet:
PRAJWAL. C
Browser:
Browser is a client side application which is used to send requests and get
URL:
Ex: https://www.instagram.com
DNS:
Server:
Http:
Https:
Static Webpage:
Or
These are the webpages which will display the same information for all users.
Dynamic Webpage:
PRAJWAL. C
These websites consist of only one web page.
—-----------------------------------------------------------------------------
HTML
HTML:
Html stands for Hyper Text Markup Language.
It helps us to create web pages.
The current version of html is html5.
Structure of HTML:
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
</body>
</html>
Doctype html:
It is used to declare the version of html as html5.
Html:
It is the root element which contains the head section and body section.
Head:
It holds the meta data.
PRAJWAL. C
Title:
It will provide the title to the webpage.
Body:
This is the place where we have to write all the code which has to be
displayed on UI.
Tags
Tags are the predefined keywords which are enclosed in angular braces.
The task of each tag has been already declared.
Syntax:
<tagname> content </tagname>
Ex:
<p> Hello world </p>
<b> Hello world </b>
Types of Tags:
HTML tags were categorized into 2 ways.
They are:
1. Paired Tags
2. UnPaired Tags
Paired Tags:
A tag which is required of both opening and closing tags are called paired tags.
Ex: <p> Hello Web Dev </p>
Unpaired Tags:
A Tag which does not require a closing tag is called unpaired tag.
Ex: <br> , <hr> , <input>
Heading Tags
Heading Tags are basically used to provide title or subtitle to the content in the webpage.
We have a set of heading tags from h1 to h6.
Where h1 is highest in font size and h6 is lowest in font size.
Default Sizes:
h1 → 2 em
PRAJWAL. C
h2 → 1.5 em
h3 → 1.17 em
h4 → 1 em
h5 → 0.83 em
h6 → 0.67 em
Note: 1 em = 16px
Formatting Tags
Deprecated Tags:
These are the tags which will be removed in further versions.
PRAJWAL. C
Element
1. Inline Level
2. Block Level
Inline Level:
● We cannot assign height and width properties for the inline elements.
Block Level:
PRAJWAL. C
● We can assign height and width properties for the block elements.
Attributes
Image Tag
It is an inline-block element.
Anchor Tag
Anchor tag helps us to navigate from one web page to another webpage.
Syntax:
PRAJWAL. C
To call a person we have to use tel:
Attributes:
Default colors:
Marquee Tag
Syntax:
Whatever we provide in the content place will scroll, content like text / images / anchor
Attributes:
PRAJWAL. C
Lists
They are:
1. Ordered List
2. Unordered List
3. Description List
1. Ordered List:
● Tags:
● Attributes:
Values = 1 (default) , A , a , I , i
2. Unordered List:
● Unordered List is used to display a set of related items with special symbols.
● Tags:
● Attributes:
PRAJWAL. C
3. Description List:
● Description List is used to display the description data along with description
terms.
● Tags:
Tables
HTML Tables allow us to store the data in the form of rows and columns.
Tags:
Attributes:
○ Cellpadding → It will provide the space between the content and cell border.
PRAJWAL. C
○ Rowspan → It will merge the cells over the rows.
Forms
Form is a block level element and most of the form elements are inline level.
Tags of Form:
1. form
2. label
3. input
4. select
5. optgroup
6. option
7. datalist
8. fieldset
9. legend
10. textarea
11. button
Form:
Ex:
<form>
.
.
form elements
.
.
PRAJWAL. C
</form>
Label:
Input:
It helps to receive the user input.
To link label tag and input tag we have to use for and id attributes.
<label for="userName">Name:</label>
<input type="text" id="userName">
<label for="userEmail">Email:</label>
<input type="email" id="userEmail">
Select:
Optgroup:
Option:
Ex:
<label>Skills:</label>
PRAJWAL. C
<optgroup label="database">
<option value="SQL">SQL</option>
<option value="MongoDB">MongoDB</option>
</optgroup>
<optgroup label="backend">
<option value="Python">Python</option>
<option value="Java">Java</option>
<option value="NodeJs">NodeJs</option>
</optgroup>
</select>
Datalist:
Datalist is also used to create a dropdown list just like select tag.
Ex:
<label>Skills:</label>
<input list="skillsList">
<datalist id="skillsList">
<option value="React">React</option>
<option value="Angular">Angular</option>
<option value="SQL">SQL</option>
<option value="MongoDB">MongoDB</option>
<option value="Python">Python</option>
<option value="Java">Java</option>
<option value="NodeJs">NodeJs</option>
</datalist>
Fieldset:
This tag is used to group the set of fields together that will display a border to
those fields.
PRAJWAL. C
Legend:
Ex:
<fieldset>
<legend>Personal Details</legend>
.
.
form elements
.
.
</fieldset>
Textarea:
rows and cols attributes specify the visible height and width of textarea.
Ex:
Button:
Ex:
<button type="reset">Reset</button>
<button type="submit">Submit</button>
1. type
2. id
3. name
4. value
5. list
6. multiple
PRAJWAL. C
7. readonly
8. disabled
9. required
10. placeholder
11. min
12. max
13. minlength
14. maxlength
15. step
16. size
17. autofocus
18. autocomplete
19. pattern
1. text
2. email
3. password
4. number
5. tel
6. radio
7. checkbox
8. button
9. submit
10. reset
11. search
12. date
13. time
PRAJWAL. C
14. datetime-local
15. week
16. month
17. color
18. image
19. file
20. url
21. range
1. Action:
2. Method:
Get:
Post:
Data is secure.
3. Novalidate:
4. Auto complete:
PRAJWAL. C
Semantic Tags
Semantic tags are the tags which will say the purpose of it.
Example:
Header , nav , section , article , aside , main , table , form , audio , video , etc..
Audio Tag
Attributes:
PRAJWAL. C
4. loop → It will repeat the song
Video Tag
Attributes:
Iframe Tag
Iframe tag is used to embed another web page into the current web page.
We can embed from internal web pages as well as external web pages like youtube , google
maps etc…
Attributes:
—-----------------------------------------------------------------------------
PRAJWAL. C
CSS
Introduction
CSS Rule:
selector{
propertyName1: value1;
propertyName2: value2;
.
.
.
propertyNameN: valueN;
}
Types of CSS
1. Inline CSS:
It is a way of applying the CSS in the same line.
By using style attribute.
Ex:
PRAJWAL. C
dive into CSS</h1>
2. Internal CSS:
It is a way of adding the CSS in the same html file itself.
By using Style Tag.
We can use style tag anywhere in the html file. It’s recommended to use in a
head tag.
Ex:
<html>
<head>
<title>Document</title>
<style>
h1 {
color: white;
background-color: blue;
}
</style>
</head>
<body>
<h1>Let's dive into CSS</h1>
</body>
</html>
3. External CSS:
It is a way of writing all the css code in one file which is saved with .css
extension.
That css file we have to link to the html file by using the link tag.
PRAJWAL. C
<h1>Let's dive into CSS</h1>
</body>
</html>
/* style.css */
h1 {
color: white;
background-color: blue;
}
Note:
1. The first will always be taken by inline CSS. because of the most recent
update.
2. Internal vs External depends on code flow which is written at last.
CSS Selectors
To apply the css Properties, we can target the html elements in many ways.
They are:
1. Simple Selector
2. Combinator Selector
3. Pseudo Class Selector
4. Pseudo Element Selector
5. Attribute Selector
Selectors
PRAJWAL. C
1. Simple Selectors:
To target the element based on classes / id’s / tagname we have basic selectors.
They are:
1. TagName
2. Grouping
3. Universal
4. Id Name
5. Class Name
● TagName:
○ To target the element based on tagname itself we have to use
tagName selector.
○ The symbol was the tagname itself.
● Grouping:
○ To target multiple elements at a time we have to use a grouping
selector.
○ Whenever we need to pass similar properties for multiple elements
we can use a grouping selector.
○ The symbol used to combine all elements is comma (,)
● Universal:
○ It will target all the elements in the document including body tag too.
○ The symbol used is asterisk (*).
● Id Name:
○ To target the elements uniquely we have to use an id name.
○ In CSS id name can be duplicated also there is no problem,
○ But once we moved to advanced languages.
○ Repetition of id name will not work. So it is highly recommended not
to use it from now on.
○ The Symbol used is hash (#).
● Class Name:
○ To target the specific elements on the basis of class name we have to
use class name.
○ Class attribute allows multiple identifier names in the same attribute.
○ Class names can be repetitive also.
○ The symbol used is dot (.).
PRAJWAL. C
2. Combinator Selectors:
It is a combination of 2 simple selectors.
Based on the relation b/w 2 elements the css will target the elements.
They are:
1. Descendent Selector
2. Direct Child Selector
3. Adjacent Sibling Selector
4. General Sibling Selector
● Descendent Selector:
○ It will target all the children, grandchildren , great grandchildren and
so on.
○ The symbol used is space ( ).
● Direct Child Selector:
○ It will target only the children but not grandchildren , great
grandchildren and so on.
○ The symbol used is greater than ( > ).
● Adjacent Sibling Selector:
○ It will target only the first sibling of the element.
○ The symbol used is plus ( + ).
● General Sibling Selector:
○ It will target all the first siblings of the element.
○ The symbol used is plus ( + ).
PRAJWAL. C
● :nth-of-type() → It will target the nth child of each type.
● :checked → It will apply the css properties once after checked.
5. Attribute Selectors
It will target the elements based on attribute name.
Instead of creating new id names and class names we can use existing attributes.
1. TagName[attribute]
2. TagName[attribute=”Value”]
Text Properties
Text Properties are basically used to apply CSS effects on text content.
Text properties are:
1. color
2. text-align
3. text-transform
4. text-decoration
5. text-indent
6. text-wrap
7. letter-spacing
8. word-spacing
9. line-height
10. text-shadow
PRAJWAL. C
1. color:
It will change the color of the text.
Syntax: color : value;
Values = Any Color.
2. text-align:
It is used to align the content based on the value.
Syntax: text-align : value;
Values = left / start , center , right / end , justify
3. text-transform:
It will convert the text into other formats.
Syntax: text-transform : value;
Values = lowercase , uppercase , capitalize.
4. text-decoration:
It will decorate the text by providing underlines or overlines with special styles.
It is a shorthand property of text-decoration-line , text-decoration-style &
text-decoration-color.
Syntax: text-decoration: text-decoration-line text-decoration-style
text-decoration-color
Values=
text-decoration-line ⇒ underline , overline , line-through
text-decoration-style ⇒ solid , dashed , dotted , double , wavy.
text-decoration-color ⇒ any color.
Note: out of 3 properties text-decoration-line is mandatory.
5. text-indent:
It will provide the space at the initial position of the content.
Syntax: text-indent : value;
Values = any number.
6. text-wrap:
It will indicate whether to wrap the content into the next line or not.
Syntax: text-wrap : value;
PRAJWAL. C
Values = wrap , nowrap.
7. letter-spacing;
It will specify the space between the letters.
Syntax: text-spacing : value;
Values = any number.
8. word-spacing:
It will specify the space between the words.
Syntax: text-spacing : value;
Values = any number.
9. line-height:
It will specify the height of the line.
Syntax: line-height : value;
Values = any number.
10. text-shadow:
It will specify the shadow for text content.
Syntax: text-shadow : x-axis y-axis blur color;
Default values: text-shadow : 0px 0px 0px black;
Ex: text-shadow : 2px 2px 3px blue;
Font Properties
Font properties are used to apply CSS effects of size , boldness , styles , etc.
Font properties are:
1. font-size
2. font-weight
3. font-style
4. font-family
5. font-variant
1. font-size:
It will specify the size of text content.
PRAJWAL. C
Syntax: font-size: value;
Values = xx-small , x-small , small , medium , large , x-large , xx-large , any number.
2. font-weight:
It will specify the boldness of the content.
Syntax: font-weight: value;
Values = 100 - 900 , lighter , normal , bold / bolder.
3. font-style:
It will specify the style of text like it should be italic or normal.
Syntax: font-style : value;
Values = normal , italic / oblique.
4. font-family:
It will specify the font family of text content.
Syntax: font-family : value;
Values = 1. From vs code 2. Google fonts.
5. font-variant:
It will be displayed in upper camel case formats.
Syntax: font-variant : value;
Values = normal , small-caps
Background Properties
1. background:
It is a shorthand property of multiple background properties.
Instead of writing all properties we can pass all values over here.
2. background-color:
It will specify the background color of an element.
PRAJWAL. C
Syntax: background-color : value;
Values = Any color.
3. background-image:
It will specify the background image of an element.
Syntax: background-image : value;
Values = url(“pathaddress”).
4. background-repeat:
By default,the background image will repeat.
To prevent repetition of images we can use this property.
Syntax: background-repeat: value;
Values = repeat , no-repeat , repeat-x , repeat-y
5. background-position:
It will specify the position of the background image.
It is a shorthand property of background-position-x and background-position-y.
Syntax: background-position : background-position-x background-position-y
Values = background-position-x ⇒ left , center , right
Background-position-y ⇒ top , center , bottom
6. background-size:
It will specify how to fit the image into a container.
Syntax: background-size : value;
Values = auto , contain , cover.
7. background-attachment:
It will decide the behavior of the background image. That has to scroll or fixed.
Syntax: background-attachment : values;
Values = scroll , fixed.
Border Properties
Border properties are used to apply the CSS effects to the border of an element.
1. border:
It is a shorthand property of border-width , border-style and border-color.
Syntax: border: border-width border-style border-color
PRAJWAL. C
2. border-width:
It will specify the width of the border.
Syntax: border-width: any number;
3. border-style:
It will specify the style of the border.
Syntax: border-style:Values;
Values: solid , dashed , dotted , double , groove , ridge , none.
4. border-color:
It will specify the color of the border.
Syntax: border-style: any color;
5. border-top/bottom/left/right:
If we need to specify the border only at one side we can use border - top / border
- bottom / border - left / border-right.
6. border-collapse:
This is a property to apply effects on tables.
It will decide whether the table cells have to separate or not.
Syntax: border-collapse: values;
Values: separate , collapse.
7. border-spacing:
It is an alternative to the cellspacing attribute of a table tag.
It will specify the space b/w cells in a table.
Syntax: border-spacing : any number;
Box Model
By default, each and every element has default padding and margin.
These default values will disturb our websites when we are layouting the webpages.
To come out of these problems mainly we use this box model concept.
PRAJWAL. C
This model contains mainly 4 boxes.
1. Content box
2. Padding box
3. Border box
4. Margin box
1. Content:
It specifies the content area of an element.
It includes content height and width (not element height & width).
2. Padding:
It specifies the space between border and content of an element.
Ex: padding: 5px;
padding: 10px;
3. Border:
It specifies the border to an element.
Ex: border : 2px solid blue;
4. Margin:
It specifies the space around the element.
Ex: margin: 5px;
margin: 10px;
PRAJWAL. C
Note: margin is a shorthand property of margin-top , margin-bottom , margin-left ,
margin-right.
We can pass
Margin : 10px 20px 30px 40px;
T R B L
Margin : 10px 20px 30px;
T L/R B
Margin : 10px 20px;
T/B L/R
Margin : 10px;
T/B/L/R
Same as for padding property also.
Height Calculation:
Total height of element = margin-top + border-top + padding-top + content-height +
padding-bottom + border-bottom + margin-bottom
Width Calculation:
Total width of element = margin-left + border-left + padding-left + content-width +
padding-right + border-right + margin-right
PRAJWAL. C
The main point over here is that content height is different from the rest of
properties.
For example if i specified height: 100px; padding:10px; so the total height will be
120px.
But if we need fix the size of the element we have to use box-sizing:border;
And To remove the default margin and padding of each element we have to use
margin:0; padding:0;
So we have to use
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
Box-shadow:
It will specify the shadow of an element.
Syntax: box-shadow: x-axis y-axis blur spread color inset;
Ex: box-shadow: 2px 2px 2px 3px blue;
Ex: box-shadow: 2px 2px 2px 3px blue inset;
Positions
PRAJWAL. C
4. right
1. Static:
a. It is the default value.
b. It will not perform any changes to the element.
c. Helping properties was not required.
2. Relative:
a. It will change the position of an element with respect to the original
position.
b. It will leave an empty space. It doesn’t allow other elements to occupy its
place.
3. Absolute:
a. It will change the position of an element with respect to the parent.
b. By default the parent is a viewport, if we need to change we have to pass
position:relative for parent element.
c. It will not leave any empty space. It allows other elements to occupy its
place.
d. If we provide position:absolute for all the elements , all elements will float
on each other.
e. To specify which element has to float top or bottom , we have to use the
z-index property.
4. Fixed:
a. It will fix the position of an element.
b. To fix the position we have to mention the helping properties.
5. Sticky:
a. Initially these elements will scroll until it reaches to some point.
b. Then it will stick at that position.
Note:
If we specify the position as relative / absolute / fixed / sticky elements
will float on the z-axis.
All of the above need the help properties.
We should not use top and bottom / left and right at a time.
PRAJWAL. C
Display
PRAJWAL. C
Flex
There are many properties which we can apply only to the container as well as only to the
items.
Flex-container Properties are:
1. display:flex
2. justify-content
3. align-items
4. flex-direction
5. flex-wrap
6. align-content
7. column-gap
8. row-gap
9. gap
1. display: flex:
This is the main property we must use to work with flex boxes.
By assigning this property we are able to use all flex properties.
2. Justify-content:
PRAJWAL. C
It will align the flex-items on the main axis.
Syntax: justify-content: values;
Values = start , center , end , space-between , space-evenly , space-around.
The default value is start.
3. align-Items:
It will align the flex-items on the cross axis.
Syntax: align-items: values;
Values = start , center , end , stretch , baseline.
The default value is start.
PRAJWAL. C
4. flex-direction:
It will specify the direction of flex-items.
Whether to display in row format or column format.
It will decide the main axis.
Syntax: flex-direction: values;
Values = row , column , row-reverse , column-reverse.
The default value is row.
PRAJWAL. C
5. flex-wrap:
It will specify whether to wrap the flex-items into the next line or not.
6. align-content:
It will specify the position of wrapped flex items.
PRAJWAL. C
Syntax: align-content: values;
Values = start , center , end , space-between , space-around , stretch
7. gap:
It is a shorthand property of row-gap & column-gap.
It will specify the space between the flex items.
Ex: row-gap:20px & column-gap:20px; / gap: 20px 20px;
Ex: gap:20px;
PRAJWAL. C
Flex-items Properties are:
1. order
2. align-self
3. flex-grow
4. flex-basis
5. flex-shrink
6. flex
1. Order:
It will arrange the flex-items in an order.
Ex:
.item1 {
order: 4;
}
.item2 {
order: 1;
}
.item3 {
order: 2;
}
.item4 {
order: 3;
}
PRAJWAL. C
2. align-self:
By using this property, we can align the flex-items individually.
It will override the default alignment which is specified by align-items.
It will accept all the values which can be acceptable by align-items property.
The only difference is
i. align-items for container for all flex-items.
ii. align-self for items for individual flex-item.
3. Flex-grow:
It will make sure the flex-items have to fit to the flex-container.
It will increase the size of the flex–items based on remaining space.
The remaining space in a container will be divided into units and it will be
added to each flex-item based on flex-grow values.
Ex:
.item1 {
flex-grow: 0;
}
.item2 {
flex-grow: 0;
}
.item3 {
flex-grow: 0;
}
PRAJWAL. C
.item1 {
flex-grow: 1;
}
.item2 {
flex-grow: 1;
}
.item3 {
flex-grow: 1;
}
.item1 {
flex-grow: 1;
}
.item2 {
flex-grow: 2;
}
.item3 {
flex-grow: 1;
}
4. flex-basis
It is equivalent to the width property.
Ex:
.item1 {
PRAJWAL. C
width: 200px;
}
.item2 {
width: 100px;
}
.item3 {
width: 200px;
}
.item1 {
flex-basis: 200px;
}
.item2 {
flex-basis: 100px;
}
.item3 {
flex-basis: 200px;
}
5. flex-shrink:
It will shrink the size of the flex-items.
Based on the extra space required in a container to fit all the flex-items.
If there is no enough space in a container to fit all the flex-items then all
flex-items will shrink(decreases) equally and fit’s in a container.
Ex:
For example:
The width of container is 800px;
And with provided to items is 300px;
So to fit 300 + 300 + 300 = 900 px into an 800px container all items will
PRAJWAL. C
shrink equally.
But our need is that we may shrink item2 and item3 but item1 must take
300px.
So, we target item2 & item3 and specify the flex-shrink value.
6. flex:
It is a shorthand property of flex-grow , flex-shrink and flex-basis.
Ex: flex: 1
If we specify flex 1 , it will increase , decrease , and width equally.
Grid
PRAJWAL. C
b. As the width of the cell is defined here, It is not required to mention again
for the grid item.
<!-- html code --> /* CSS Code */
<html> * {
<head> margin: 0;
<title>Document</title> padding: 0;
<link rel="stylesheet" box-sizing: border-box;
href="./grid.css" /> }
</head>
<body> section {
<section> height: 500px;
<div class="item1">item1</div> width: 1000px;
<div class="item2">item2</div> background-color: bisque;
<div class="item3">item3</div> border: solid;
<div class="item4">item4</div> color: white;
</section> font-size: 25px;
</body> display: grid;
</html> grid-template-columns: 200px
200px 200px 200px;
/* It will consider as 4 columns
each with 200px width */
}
div {
background-color: chocolate;
border: dashed;
text-align: center;
}
PRAJWAL. C
3. grid-template-rows:
a. It will specify no.of rows along with the height of each column.
b. As the height of the cell is defined here, It is not required to mention again
for the grid item.
Ex:
/* CSS Code */
section {
display: grid;
grid-template-columns: 200px 200px 200px 200px;
/* It will consider as 4 columns each with 200px width */
grid-template-rows: 150px 50px 150px 30px 100px;
/* It will consider as 5 rows with widths => 1st - 150px , 2nd
- 50px , 3rd - 150px , 4th - 30px , 5th - 100px*/
}
PRAJWAL. C
We can pass the values for grid-template-rows and grid-template-columns in
multiple ways.
4. gap:
a. It will specify the space between the grid items.
b. It is the shorthand property of row-gap & column-gap.
/* CSS Code */
PRAJWAL. C
section {
row-gap: 5px;
column-gap: 20px;
===== or ======
gap: 5px 20px;
}
1. grid-row:
a. It is a shorthand property of grid-row-start and grid-row-end.
b. Grid-row-start will specify where to start the row.
c. Grid-row-end will specify where to end the row.
d. Syntax: grid-row: grid-row-start/grid-row-end
e. Ex: grid-row: 1/5;
f. Ex:
PRAJWAL. C
g.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
section {
height: 500px;
width: 1000px;
background-color: bisque;
border: solid;
color: white;
font-size: 25px;
display: grid;
grid-template-columns: repeat(4, auto);
grid-template-rows: repeat(4, auto);
}
div {
background-color: chocolate;
border: dashed;
text-align: center;
}
.item1 {
background-color: rgb(204, 138, 52);
grid-row-start: 1;
grid-row-end: 5;
======= or =======
grid-row: 1/5;
}
PRAJWAL. C
2. grid-column:
a. It is a shorthand property of grid-column-start and grid-column-end.
b. Grid-column-start will specify where to start the column.
c. Grid-column-end will specify where to end the column.
d. Syntax: grid-column: grid-column-start/grid-column-end
e. Ex: grid-column: 1/5;
f. Ex:
g.
.item1 {
background-color: rgb(204, 138, 52);
grid-column-start: 1;
grid-column-end: 5;
======= or =======
grid-column: 1/5;
}
PRAJWAL. C
3. grid-area:
a. It is the shorthand property of grid-row-start , grid-column-start ,
grid-row-end and grid-column-end.
b. Syntax: grid-row-start/grid-column-start/grid-row-end/grid-column-end.
c. Ex:
d.
.item1 {
background-color: rgb(204, 138, 52);
grid-area: 1/1/3/5;
}
PRAJWAL. C
Transform
Transform will change the state of an element like changing position , applying
rotations , altering sizes, etc…
======== or ===========
It will transform the elements original behavior with new behaviors like changing
positions , applying rotations , altering sizes , etc..
Syntax: transform: value;
Values: translateX() translateY() translate()
scaleX() scaleY() scale()
skewX() skexY() skew()
rotateX() rotateY() rotate()
Translate():
It will change the position of an element according to x-axis and y-axis.
It is a shorthand property of
translateX() → which will according to x-axis
And
translateY() → which will according to y-axis
Ex: transform: translateX(200px);
transform: translateY(400px);
transform: translate(200px , 400px);
Scale():
It will alter the sizes of an element based on the scale value provided either to
increase or decrease.
By default, the scale is 1.
Ex: transform: scaleX(2); // It will increase the width into double.
transform: scaleY(0.5); // It will decrease the height into half.
transform: scale(2,0.5); // It will increase the width & decrease the height.
Skew():
It will slant the elements in x and y axises.
Ex: transform: skewX(40deg);
transform: skewY(20deg);
transform: skew(40deg , 20deg);
PRAJWAL. C
Rotate():
It will rotate the element in clockwise and anticlockwise directions.
Ex: transform: rotateX(90deg);
transform: rotateY(180deg);
transform: rotate(90deg); // clockwise
transform: rotate(-90deg); // anticlockwise
Transition
Transition-property:
It will specify which properties have to be targeted. (In hover we will have many
properties , for which property transition have to apply).
If we are not targeted specifically, It will target all.
Transition-duration:
It specifies how long the transition has to occur.
The default is 0 secs.
Transition-delay:
It specifies when the transition has to apply.
Basically, it provides a delay time. So transition will start after that time.
The default is 0 secs.
Transition-timing-function:
It specifies the speed format of transition.
We can assign the values like
ease-in → slow start
ease-out → slow end
PRAJWAL. C
ease-in-out → slow start and slow end
ease → slow start , fast , slow end
linear → same speed
Animation
Animations will change the style of an element from one style to another style to
another style and so on.
Animation is a shorthand property of
Animation-name
Animation-duration
Animation-delay
Animation-timing-function
Animation-direction
Animation-iteration-count
As we said, animation will change from one style to another and so on. To store all these
styles we have to use @keyframes rule.
Syntax:
@keyframes identifier {
from{
// code
}
to{
// code
}
Animation-name:
It specifies the animation-name which is nothing the @keyframes rule identifier
name.
We can create @keyframes rules with different styles.
Which animation you want to use, you can specify that identifier name.
Animation-duration:
PRAJWAL. C
It specifies how the animation has to apply.
Animation-delay:
It specifies when the animation has to start.
Animation-timing-function:
It specifies the speed format of animation.
We can assign the values like
ease-in → slow start
ease-out → slow end
ease-in-out → slow start and slow end
ease → slow start , fast , slow end
linear → same speed
Animation-direction:
It specifies the direction of animation.
We can assign the values normal , reverse , alternate and alternate-reverse.
Animation-iteration-count:
It specifies how many times the animation has to apply.
We can assign any number or infinite.
CSS Units
● In CSS, Units will specify the length of an element / size of content.
● Units were categorized into 2 Ways
● They are:
1. Absolute Units
2. Relative Units
Absolute Units:
These units are static, It will not depend on any other values.
Absolute Units are:
1. mm
2. cm
3. in
4. Px
Relative Units:
PRAJWAL. C
These units are dynamic, It will depend on some other values.
Relative Units are:
1. vw → depends on viewport width
2. vh → depends on viewport height
3. % → depends on parent element
4. rem → depends on root element
5. em → depends on parent element
CSS Responsiveness
To achieve responsiveness, mainly we have to use @media rule.
@media:
Basically, this @media rule will provide some features.
Features like mediaType, mediaOperator and mediaFeatures which will work as
conditions. If these conditions are satisfied then a particular block of code will be
executed.
Syntax:
@media mediaType mediaOperator mediaFeatures{
// code
MediaType:
It will specify the type of view mode.
It will accept the values like all, screen , print.
The default value is all.
MediaOperator:
This will combine multiple media features.
It will accept the values like and , or , not.
And → it will check if all the conditions are true or not.
Or → it will check if any of the conditions are true or not.
MediaFeatures:
It will provide some breakpoints based on screen sizes.
It will accept the values like:
PRAJWAL. C
1. min-width
2. max-width
3. width
4. min-height
5. max-height
6. height
7. orientation: landscape / portrait
Ex:
@media screen and (min-width:0px) and (max-width:400px){
h1::after{
content: "Mobile View";
}
body{
background-color: teal;
}
h1::after{
content: "Tablet View";
}
body{
background-color: cadetblue;
}
@import:
It will import the css files into a css file based on media conditions
Ex:
@import url(./mobileCodePathAddress) (min-width:0px) and (min-width:400px);
PRAJWAL. C
@import url(./printCode.css) print;
-----------------------------------------------------------------------------------------------------------
JavaScript
PRAJWAL. C