M19 Webtech Notes
M19 Webtech Notes
Basic Terminologies
Web: Short for the World Wide Web, a collection of web pages and resources
accessible through the internet.
Server
A server is a computer or a system where all the websites are hosted. It handles
the request of the user 24 x 7. For a valid request server will give the response
and it contains logics and business logics.
Client: A device (e.g., your computer or smartphone) that requests web content
from a server.
URL (Uniform Resource Locator): The web address used to locate a specific
webpage (e.g., [Link]
DNS (Domain Name System): Translates domain names (like [Link])
into IP addresses.
HTTP/HTTPS: Protocols used for transferring data between a client and server.
Static →Static pages are those pages in which the information will be same for
each and every User .
There are two types of Web Applications 1. Single page 2. Multipage Application
MultPage Application
1. Contains multipages
2. It will reload in every Request made by user
Example →
Steps
1. When you type a URL (website address) in the browser and press
enter.
2. The browser sends a request to a DNS server (Domain Name
System).
3. The DNS server translates the domain name (like [Link])
into its corresponding IP address (a unique number assigned to a
website).
4. Then, the DNS server sends back this IP address to the browser as a
response.
5. Now, the browser sends an HTTP or HTTPS request to the server
using this IP address.
6. The server processes the request and sends back a response to the
browser. This response contains the website’s files like HTML, CSS,
and JavaScript.
7. The browser receives these files and displays the web page on the
screen, allowing the user to see and interact with it.
HTML
● Html stands for Hyper Text Markup Language.
● It is used to structure a webpage.
● It also used to add content to the webpage.
CSS
● CSS stands for Cascading Style Sheets
● It is used to style and add alignment to the web page.
JavaScript
● It is used to add some functionality to our web pages
HTML
HTML
HTML (HyperText Markup Language) is the most basic building block of the
Web. It is used to Create the structure of a webpage and along with that it will
help out to add the content in webpage .
Content like → images , audios , text , videos etc
History Of HTML
● 1991: Tim Berners-Lee invented HTML 1.0
● 1993: HTML 1.0 was released
● 1995: HTML 2.0 was published, which added new features to HTML 1.0
● 1997: HTML 3.0 was invented, which improved HTML features and gave
webmasters more capabilities
● 1999: HTML 4.01 was released and became the official standard
● 2014: HTML 5.0 was released and used worldwide
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.
It is the container for all other HTML elements
Head
It holds the meta data about the html document. such as title, styles, and
scripts
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
HTML Tags are predefined keywords that are enclosed in angular brackets (< >). Each
tag has a specific predefined task or purpose
Syntax:
<tagname> content </tagname>
Ex:
<p> Hello world </p>
<b> Hello world </b>
Types of Tags:
1. Paired Tags
2. UnPaired Tags
Paired Tags:
A tag which is required of both opening and closing tags are called paired tags.
They also known as Container tag.
Ex: <p> Hello Web Dev </p>
Unpaired Tags:
A Tag which does not require a closing tag is called unpaired tag.
They are also Known as , void tags , empty tags , Self closing tags
Element
1. Inline Level
2. Block Level
[Link]-block Level
Inline Level:
We cannot assign height and width properties for the inline elements. Ex:
<b> , <i> , <span> , etc…
Block Level:
We can assign height and width properties for the block elements.
Inline-Block-Level
Inline level Elements are those elements which are having both the behaviour block and
inline level elements , They will take content height and content width only along with that
they will accept height and width
Heading Tags
Heading Tags are basically used to provide title or subtitle to the content in the
webpage.
Default Sizes:
h1 → 2 em
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
Formatting Tags are used to display the content in different formats.
strong → It will display the content in bold format and the browser will
understand that information is very important.
em → It will display the content in Italic format and it is an alternative to the <i>
tag.
del → It will strike off the content and it is the alternative to <strike> tag.
pre → It will consider space also. It will also be known as a pre structured tag.
Deprecated Tags:
These are the tags which will be removed in further versions.
Examples
Main Document Structure
Text Content
● <p> – Paragraph.
Attributes
HTML attributes are used to define the characteristics of an HTML element.
Types of Attributes
[Link] Attributes
These are basic attributes that can be applied to most HTML elements.
[Link] Attributes
These are the element specific attributes .
● src
● href
● alt
● height and width
[Link] Attributes
● contenteditable
● tabindex
● Accesskey
1. contenteditable
The contenteditable attribute specifies whether the content of an element is editable by
the user.
Ex →
<div contenteditable="true">You can edit this text!</div>
<div contenteditable="false">This text is not editable.</div>
3. tabindex
The tabindex attribute specifies the tab order of an element when navigating through
the page using the Tab key. It controls the sequence of focusable elements.
[Link]
The accesskey attribute specifies a shortcut key (keyboard combination) that can be
used to activate or focus a specific HTML element, such as a link, button, or form field.
5. Title
This attribute is used to provide the toolTip for the html elements
Lists
HTML Lists allows to group a set of items together and will display the items on UI.
They are:
1. Ordered List
2. Unordered List
3. Description List
1. Ordered List:
Ordered List is that list in which they have some sequence , and by default sequence
will be number , so it also known as numbered list
● Tags:
● Attributes:
2. Unordered List:
An unordered list is that list in which we don't have any sequence instead of that list
style. It is there by default disc or bullet so It is also known as a bulleted list.
● Tags:
● Attributes:
none|
3. Description List:
● Tags:
3. Nested List :
● List inside another list is nothing but the Nested List , it can be
Oredered , unordered , Description .
<th> Table header – similar to <td> but makes text bold &
centered.
Attribute Description
border Adds a border around the table and cells.
Task on table
Image
● <img> tag is used to display images on a webpage.
Attributes of <img>
Attribute Description
alt Alternative text – shown when image is not loaded, also used by screen readers
(for accessibility).
Src attribute will accept two types of path 1. Relative Path , 2. Absolute Path
Form
HTML form is a container element (<form>) used to collect user input and send it to a
server for processing
Syntax
<form action="">
</form>
1. <form>
2. <label>
<label for="userName">Name:</label>
<label for="userEmail">Email:</label>
3. <select>
4. <optgroup>
5. <option>
<label>Skills:</label>
<select name="userSkills" multiple>
<optgroup label="Frontend">
<option value="React">React</option>
<option value="Angular">Angular</option>
</optgroup>
<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>
6. <datalist>
Example: Datalist
<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>
7. <fieldset>
8. <legend>
<fieldset>
<legend>Personal Details</legend>
</fieldset>
9. <textarea>
Example: Textarea
10. <button>
Example: Button
<button type="reset">Reset</button>
<button type="submit">Submit</button>
Anchor tag helps us to navigate from one web page to another webpage.
Syntax:
Whatever we give as the content to the anchor tag that becomes a hyperlink.
Attributes:
Default colors:
Audio Tag
The <audio> tag is used to include audio files on a webpage.
Syntax: <audio src="path address"></audio>
Attributes:
1. src → It will specify the path address
2. controls →Displays play, pause, and volume controls for the user.
3. autoplay → It will play the song automatically when the page loads
4. loop → Makes the audio replay continuously after finishing.
5. muted → Starts the audio with the volume muted.
Video Tag
The <video> tag is used to include video files on a webpage.
Syntax: <video src="path address"></video>
Attributes:
1. src → It will specify the path address
2. controls →Displays play, pause, volume, and fullscreen controls for the
user
3. autoplay →Automatically starts playing the video when the page loads
(should include muted for autoplay).
4. loop → Makes the video replay continuously after finishing.
5. muted → Starts the video without sound.
6. Poster → Specifies an image to display before the video starts
playing.(thumbnail)
Marquee Tag
Marquee tag implements scrollable content in our webpages.
Syntax:
Whatever we provide in the content place will scroll, content like text / images / anchor
Attributes:
Video Tag
The <video> tag is used to include video files on a webpage.
Syntax: <video src="path address"></video>
Attributes:
1. src → It will specify the path address
2. controls →Displays play, pause, volume, and fullscreen controls for the
user
3. autoplay →Automatically starts playing the video when the page loads
(should include muted for autoplay).
4. loop → Makes the video replay continuously after finishing.
5. muted → Starts the video without sound.
6. Poster → Specifies an image to display before the video starts
playing.(thumbnail)
[Link] and height: Define the dimensions of the video player.
Iframe Tag
Iframe tag is used to embed another web page into the current web page. We can
embed internal web pages as well as external web pages like youtube , google maps
etc…
Syntax : <iframe src="" frameborder="0" height="" width=""></iframe>
Attributes:
1. src → It will specify the path address
2. frameborer→Specifies whether the iframe should have a border (0 for
no border, deprecated in HTML5).
7. width and height: Define the dimensions of the iframe.
Embedding Map
Steps to Embed a Map
1. Open Google Maps
2. Get the Embed Code
3. Add the Code to Your Webpage
Generating QR Code
You can use free APIs like Google Chart API or QR Code Generator APIs to dynamically
create QR codes.
1. Go to goqr website and get the api (qr code generator api)
[Link]
[Link]
2. Replace the Example with the your website path address
3. Use img tag and pass the complete path to src
4. You can change the qr size also by using height and width attribute or passing values to
the size in path address
HTML Entities
Some characters are reserved in HTML.
If you use the less than (<) or greater than (>) signs in your HTML text, the
browser might mix them with tags.
Entity names or entity numbers can be used to display reserved HTML characters.
Example →
To display a less than sign (<) we must write: < or <
CSS
CSS
CSS stands for Cascading Style Sheets
CSS describes how elements in a web page should be displayed on screen
CSS is used to style and provide layout to the webpage
CSS History
1994
Håkon Wium Lie, a Norwegian technologist at CERN, proposed the idea
of CSS after noticing that there was no way to style documents on the
web.
1996
The first version of CSS, CSS1, was adopted by the World Wide Web
Consortium (W3C).
1998
CSS 2 was released, and work on CSS 3 began.
2011
CSS 3 was released
CSS Syntax
Multiple CSS declarations are separated with semicolons, and declaration blocks
are surrounded by curly braces.
1. Inline CSS
An inline style is used to apply a unique style for a single element.
To use inline styles, add the style attribute to the relevant element. The style
attribute can contain any CSS property.
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 you can link with multiple html files by using the link tag inside the <head>
section
It makes the stylesheet reusable
<!-- [Link] →
<html>
<head>
<title>Document</title>
<link rel="stylesheet" href="./[Link]" />
</head>
<body>
<h1>Let's dive into CSS</h1>
</body>
</html>
/* [Link] */
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
CSS selectors are used to select and style specific elements in an HTML document.
To apply the css Properties, we can target the html elements in many ways. They are:
1. Simple Selector
2. Combinator Selector
5. Attribute Selector
1. Simple Selector
These selectors target elements based on their tag names, IDs, and classes. Here are
the basic selectors:
1. Id (#)
2. Class (.)
3. Tagname
1. Grouping Selector (,)
2. Universal (*)
Grouping Selector
● Groups multiple elements and applies the same style to them.
● Syntax: Separate selectors by a comma.
● Example: h1, h2, h3 { font-family: Arial, sans-serif; }
Universal Selector
ID Selector
Class Selector
● Targets elements with a specific class name. Class names can be repeated.
● Syntax: .classname
● Example: .button { padding: 10px 15px; background-color: blue; }
2. Combinator Selectors
These selectors combine two simple selectors based on the relationship between
elements. The following are the types of combinator selectors:
Descendant Selector
3. Pseudo-Class Selectors
Pseudo-classes target elements based on their state or position in the DOM. These
selectors are preceded by a single colon (:).
:hover
Link States:
:first-child
Targets the first child element of a parent.
:last-child
Targets the last child element of a parent.
:nth-child(n)
Targets the nth child of a parent (based on number).
Pseudo element
Attribute Selector
1. [ AttributeName ]
2. [ AttributeName = “Value” ]
3. TagName[ AttributeName= “Value” ]
CSS units
Relative Units:
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
Absolute Units:
1. Px
2. In
3. cm
Text Properties
Text Properties are basically used to apply CSS effects on text content.
1. color
2. text-align
3. text-transform
4. text-decoration
5. text-wrap
6. letter-spacing
7. word-spacing
8. line-height
9. Text-shadow
● color: Changes the text color. Syntax: color: value; Values = any color.
Font Properties
Font properties are used to apply CSS effects such as text size, boldness, style,
and font family to text content.
It specifically define the visual appearance of the text itself, including font
family, size, weight, and style
1. font-size
2. font-weight
3. font-style
4. font-family
5. font-variant
1. font-size:
3. font-style:
4. font-family:
5. font-variant:
Background Properties
Background properties are used to apply effects to an element's background. The
background shorthand property combines several background-related properties into a
single declaration.
1. background
2. background-color
3. background-image
4. background-repeat
5. background-position
6. background-size
7. background-attachment
● Determines whether the background image scrolls with the page or remains
fixed.
● Syntax: background-attachment: value;
● Values:
○ scroll: Background image scrolls with the page (default).
○ fixed: Background image remains fixed in place.
8. background-blend-mode
Specifies how the background image(s) should blend with each other and with the
background color.
Syntax: background-blend-mode: value;
Values:
Linear Gradient
A linear gradient transitions colors along a straight line, either horizontally, vertically, or
at an angle.
#grad {
Radial Gradient
#grad {
}
Conic Gradient
A Conic gradient transitions colors in Conical shape from the top of the cone
#grad {
Border
Border properties allow you to customize the borders of elements with various
styles, colors, and widths.
1. border
It is a shorthand property for border-width, border-style, and
border-color.
Syntax: border: border-width border-style border-color;
2. border-width
Specifies the width(thickness) of the border.
Syntax: border-width: value;
3. border-style
Specifies the style of the border.
Syntax: border-style: value;
Values: solid, dashed, dotted, double, groove, ridge, none.
4. border-color
Specifies the color of the border.
Syntax: border-color: value;
5. border-top / border-bottom / border-left / border-right
Used to style borders for specific sides of an element
Syntax:
○ border-top: border-width border-style border-color;
○ border-bottom: border-width border-style border-color;
○ border-left: border-width border-style border-color;
○ border-right: border-width border-style border-color;
6. border-collapse
Used for tables to decide whether the table cells' borders should be
separated or collapsed.
Syntax: border-collapse: value;
Values: separate, collapse.
7. border-spacing
Specifies the space between cells in a table. It works only when
border-collapse is set to separate and is an alternative to the cellspacing
attribute in the <table> tag.
Syntax: border-spacing: value;
Box Model
By default, every HTML element has some default margin and padding. These default
values can affect the layout of our webpage. To control and manage these layout
issues, we use the Box Model concept.
The Box Model consists of four main parts:
1. Content Box
2. Padding Box
● It is the space between the content and the border of an element.
Example:
padding: 5px;
padding: 10px;
3. Border Box
Example:
border: 2px solid blue;
4. Margin Box
Example:
margin: 5px;
margin: 10px;
Margin Shorthand Property
Four values:
margin: 10px 20px 30px 40px;
●
○ Top: 10px
○ Right: 20px
○ Bottom: 30px
○ Left: 40px
Three values:
margin: 10px 20px 30px;
○ Top: 10px
○ Left & Right: 20px
○ Bottom: 30px
Two values:
margin: 10px 20px;
●
○ Top & Bottom: 10px
○ Left & Right: 20px
One value:
margin: 10px;
●
○ Applies to all four sides
The total height and width of an element include all parts of the Box Model.
Important Note:
If we specify:
height: 100px;
padding: 10px;
● The total height will be 120px (100px content + 10px padding top + 10px padding
bottom).
To fix the size of an element regardless of padding and border, use:
box-sizing: border-box;
● This ensures that padding and border are included within the specified width
and height.
To remove the default margin and padding from all elements, use:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
Border-radius
The border-radius property allows you to create rounded corners for elements by
defining the radius of their corners.
You can control each corner of an element separately using these properties:
Shorthand Property:
You can define the radius for all four corners in a single border-radius property.
Display
The display property controls how an element behaves in the document flow.
Flex
To work with flex boxes, We need a flex container and all the direct children
will become the flex-items. (ONLY DIRECT CHILDREN).
There are many properties which we can apply only to the container as well as only
to the items.
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
● 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:
★ It will align the flex-items on the main axis.
★ Syntax: justify-content: values;
★ Values = start , center , end , space-between , space-evenly , space-around.
○ flex-start (default) – Items align at the start.
○ center – Items align at the center.
○ flex-end – Items align at the end.
○ space-between – Equal space between items.
○ space-around – Equal space around items.
○ space-evenly – Equal space between and around items.
3. align-Items:
4. flex-direction:
● It will specify whether to wrap the flex-items into the next line or not.
7. gap:
Ex: gap:20px
Flex-items Properties are:
1. order
2. align-self
3. flex-grow
4. flex-basis
5. Flex-shrink
6. Flex
1. Order:
Ex:
.item1 {
order: 4;
}
.item2 {
order: 1;
}
.item3 {
order: 2;
}
.item4 {
order: 3;
}
2. Align-self:
3. Flex-grow:
● flex-grow allows flex items to grow to fill the available space in the
container along the main axis.
● It increases the size of flex items proportionally based on their flex-grow
values.
● The remaining space in the flex container is divided according to the
flex-grow values, and distributed to each item accordingly.
● Ex:
.item1 {
flex-grow: 0;
}
.item2 {
flex-grow: 0;
}
.item3 {
flex-grow: 0;
}
.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 {
flex-basis: 200px;
}
.item2 {
flex-basis: 100px;
}
.item3 {
flex-basis: 200px;
}
5. flex-shrink:
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 shrink equall
But our need is that we may shrink item2 and item3 but item1 should
not shrink.
So, we can target item2 & item3 and specify the flex-shrink value.
And for item1 we can pass the value of flex shrink as 0
6. flex:
1. display:grid
2. Grid-template-columns
3. Grid-template-rows
4. Column-gap
5. Row-gap
6. gap
1. Display:grid
2. Grid-template-columns:
a. It will specify [Link] columns along with the width of each column
</html> }
div {
background-color: chocolate;
border: dashed;
text-align: center;
[Link]-template-rows:
It will specify [Link] rows along with the height of
each column.
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;
grid-template-columns: repeat(4,1fr);
4. gap:
a. It will specify the space between the grid items.
b. It is the shorthand property of row-gap & column-gap.
section {
row-gap: 5px;
column-gap: 20px;
===== or ======
}
Grid Items Properties are:
1. grid-row-start
2. grid-row-end
3. grid-column-start
4. grid-column-end
5. grid-row
6. grid-column
7. grid-area
1. grid-row:
Ex:
|
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;
}
|
2. grid-column:
f. Ex:
g.
.item1 {
grid-column-start: 1;
grid-column-end: 5;
======= or =======
grid-column: 1/5;
|
3. grid-area:
Ex:
.item1 {
grid-area: 1/1/3/5;
}
CSS Positions
The position property is used to control the placement of elements on a webpage.
Types of Positioning:
1. Static
2. Relative
3. Absolute
4. Fixed
5. Sticky
● top
● bottom
● left
● right
1. Static Positioning
2. Relative Positioning
Example:
position: relative;
top: 20px; /* Moves the element 20px down from its original position */
left: 10px; /* Moves the element 10px to the right */
3. Absolute Positioning
● Moves the element relative to the nearest positioned ancestor (an element
with position: relative;, absolute;, or fixed;).
● If no positioned ancestor exists, it is positioned relative to the viewport.
● The element does not reserve space in the normal document flow—other
elements will take its place.
● If multiple elements have position: absolute;, they overlap each other.
● To control overlapping, use the z-index property.
Example:
.parent {
position: relative;
}
.child {
position: absolute;
top: 50px;
left: 30px;
}
4. Fixed Positioning
● The element is positioned relative to the viewport and does not move even
when scrolling.
● Requires helper properties (top, bottom, left, right) to define its position.
Example:
position: fixed;
top: 0;
left: 0;
width: 100%;
background: black;
color: white;
5. Sticky Positioning
● Acts like relative until the element reaches a certain scroll position, then it sticks
in place like fixed.
Example:
position: sticky;
top: 50px; /* The element will stick at 50px from the top when scrolling */
Important Notes:
Translate():
The translate() function moves an element along the x-axis and y-axis without affecting
its size or shape.
It is a shorthand for:
transform: translateY(400px);
Scale():
The scale() function increases or decreases the size of an element based on the
provided scale value.
By default, the scale value is 1, meaning no change in size.
Skew():
The skew() function tilts an element along the x-axis and y-axis, creating a
slanted effect.
transform: rotateY(180deg);
Transition
It is a shorthand property of
Transition-property
Transition-duration
Transition-delay
Transition-timing-function
Transition-property:
Transition-duration:
Transition-delay:
Transition-timing-function:
Common values:
button {
background-color: blue;
color: white;
border: none;
cursor: pointer;
button:hover {
background-color: red;
transform: scale(1.1);
Animation
Animations will change the style of an element from one style to another style
to another style and so on.
@keyframes rule
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 {
0%{
// code
50%{
// code
}
100%{
//CODE
}
}
Animation-name:
Defines the name of the animation, which must match an @keyframes identifier.
Animation-duration
Animation-delay:
Defines how long the animation should wait before starting.
Animation-timing-function:
Animation-direction:
Values:
Animation-iteration-count:
Values:
Example
@keyframes slide {
from {
transform: translateX(-100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.box {
width: 100px;
height: 100px;
background-color: blue;
animation: slide 2s ease-in-out 0.5s infinite alternate;
}
Transform
Translate():
The translate() function moves an element along the x-axis and y-axis without affecting
its size or shape.
It is a shorthand for:
transform: translateY(400px);
Scale():
The scale() function increases or decreases the size of an element based on the
provided scale value.
By default, the scale value is 1, meaning no change in size.
Skew():
The skew() function tilts an element along the x-axis and y-axis, creating a
slanted effect.
transform: rotateY(180deg);
Transition
It is a shorthand property of
Transition-property
Transition-duration
Transition-delay
Transition-timing-function
Transition-property:
Transition-duration:
Transition-delay:
Transition-timing-function:
Common values:
button {
background-color: blue;
color: white;
border: none;
cursor: pointer;
button:hover {
background-color: red;
transform: scale(1.1);
Animation
Animations will change the style of an element from one style to another style
to another style and so on.
@keyframes rule
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 {
0%{
// code
50%{
// code
}
100%{
//CODE
}
}
Animation-name:
Defines the name of the animation, which must match an @keyframes identifier.
Animation-duration
Animation-delay:
Defines how long the animation should wait before starting.
Animation-timing-function:
Animation-direction:
Values:
Animation-iteration-count:
Values:
Example
@keyframes slide {
from {
transform: translateX(-100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.box {
width: 100px;
height: 100px;
background-color: blue;
animation: slide 2s ease-in-out 0.5s infinite alternate;
}
CSS Units
In CSS, units specify the length of an element or the size of its content.
1. Absolute Units
These units are static and do not depend on any other values.
● mm → Millimeters
● cm → Centimeters
● in → Inches
● px → Pixels
2. Relative Units
@media Rule
The @media rule provides features to apply styles based on conditions such as screen
size, device type, or orientation.
Syntax:
/* CSS Code */
Values:
2. Media Operator
Values:
3. Media Features
Examples:
Example:
@media screen and (min-width: 0px) and (max-width: 400px) {
h1::after {
body {
background-color: teal;
h1::after {
body {
background-color: cadetblue;
Extra Things
overflow Property
The overflow property in CSS controls how content is displayed when it exceeds the size
of its container. It is commonly used to manage scrollbars and prevent content
overflow.
Syntax
selector {
overflow: value;
}
Example:
div {
width: 200px;
height: 100px;
overflow: visible;
}
Example:
div {
width: 200px;
height: 100px;
overflow: hidden;
}
3. scroll
○ Adds scrollbars (horizontal and vertical) even if the content fits.
Example:
div {
width: 200px;
height: 100px;
overflow: scroll;
}
The overflow property can be applied separately for horizontal (overflow-x) and
vertical (overflow-y) scrolling.
div {
overflow-x: scroll; /* Horizontal scrollbar */
overflow-y: hidden; /* No vertical overflow */
}
1. Declaring a Variable
CSS variables are defined inside a :root selector (or any other selector) using -- (double hyphen)
before the variable name.
:root {
--primary-color: blue;
--font-size: 16px;
}
2. Using a Variable
h1 {
color: var(--primary-color);
font-size: var(--font-size);
}
Task To be Done
Simple
1 Google Homepage Clone vanilla css
2. Instagram login page tailwind css
medium
1. Spotify landing page
2. YouTube Video Page Clone
3. Airbnb
vanilla css
Hard
1. Apple
2. Netflix
tailwind