Css
Css
What is CSS
It allows customization for web content with out changing the HTML structure
CSS Syntax
SELECTOR{
color: red;
background-color: blue;
}
Types Of Styles
They are :-
3. External Styles:- Styles applied using external file linked in head tag using <link>
Rel Attribute
Rel attribute is used for specifies the relation between present document and the external
document.
Alternate :- Links to the alternate version of the document like (RSM or Atom).
Type attribute is used for specifies the MIME TYPE of the linked resource.
It helps to the browser to understand what type file it is dealing with before fetching the resource.
Common MIME TYPE for Type attribute
Text based files :-
text/css text/html text/javascript
Application based files :-
application/rss+xml application/json application/pdf
image files :-
image/png image/jpeg text/svg+xml
Audio/Video files :-
audio/mp3 video/mp4
Stylesheet Versioning
Common strategies:
Box model is used for calculate the dimensions of the specific element.
Every element in CSS is a rectangular box.
box model have to key concepts:
box-sizing : content box
it is a default sizing in box model.
Margin:- Margin is a spacing border outside of an element, create distance between element and
surroundings.
Padding:- padding is a spacing between the content of an element and the border of an element.
Overflow property is used for the fit in the content dimensions using several keys.
Key values:-
3. Auto :- provide the scrollbars only the content is overflow the containers.
3. Absolute Positioning
4. Fixed Positioning
5. Sticky Positioning
1. Static Positioning:- Elements appear in the normal flow of the document like writing text on paper.
position : static;
2. Relative Positioning:-
1. Elements are moved relative to their normal position.
2. It is based on the parent element position.
3. You can move the element by using top, left, right, bottom
position : relative;
3. Absolute Positioning:-
1. Elements are placed exactly specified co-ordinates.
2. It is based on the web page
3. You can move the element by using top, left, right, bottom
position : relative;
4. Fixed Positioning:- Elements are stay at the given position to the page even you scrolling.
position : fixed;
5. Sticky Positioning:- Elements are acts like relative until a scroll point, then they stick and behave like fixed.
position : stick;
CSS Units
1. Absolute Units
2. Relative Units
Absolute Units
Absolute units are fixed and do not change based on their properties.
px (pixels) : They are fixed and do not change based on any other elements.
to scale.
Use % for layout responsiveness: It adjust relative to parent elements. This is particularly useful
Use em and rem for typography and scaling: em is useful for text sizing. rem is ideal for global
size settings.
Use viewport units for viewport relative sizing: vw and vh are creating elements that adapt to the
We have several methods for laying out the elements in a structured and responsive manner.
They are :
1. Table Layout
2. Floating Layout
4. Grid Layout
1. Table Layout
Think of this as arranging content in a grid of rows and columns (like a table in MS Word or Excel).
Each cell of the table can hold text, images, or other elements.
Example: You use a table layout to present a comparison or organize data neatly in a presentation.
2. Floating Layout
This is a free-form layout, where you can place elements (text, images, shapes) anywhere on the slide
without being restricted by rows or columns.
You can drag and drop content to any position.
Example: Designing an infographic-like slide or placing an image and text freely side by side.
3. Flexbox Layout
Flexible Box layout model allows for efficient alignment and distribution of space among items in a
Key Concepts:
1 . Flex Container: The parent element that contains the flex items. Flexbox properties are applied to
2. Flex Items: The child elements within the flex container. Their arrangement and distribution are
Key Concepts
@keyframes: Define the stages of animation.
Animation Duration
Timing Function
Delay @keyframes example {
from {background-color: red;}
Iteration Count
to {background-color: blue;}
Direction }
div{
animation-name: example;
animation-duration: 4s;
animation-iteration-count:
infinite;
animation-direction: alternate;
width: 100px; height: 100px;
}
CSS Variables
Key Concepts
CSS Variables, also known as CSS Custom Properties.
CSS Variables are defined using the – prefix.
Declared variables global accessible across the entire stylesheet.
:root{
--primary-color: blue;
--secondary-color: red;
}
.btnLogin {
background-color: var(--primary-
color);
color: red;
}
.btnCancel {
background-color: var(--
secondary-color);
color: yellow;