CSS LONG
CSS LONG
2. Consistency: By using a single CSS file, styles can be consistent across multiple
pages of a website.
3. Accessibility: CSS can be used to improve website accessibility for users with
disabilities.
5. Efficiency: Instead of defining styles for each element individually, CSS lets you
define styles once and apply them to multiple elements.
7. Animations & Transitions: Modern CSS offers powerful animation and transition
capabilities.
Example:
Without CSS:
With CSS:
CSS 1
p {
font-size: 16px;
color: red;
}
3. Values: Specify the settings you want to apply for the chosen property.
8. Internal Styles: Defined within the <head> section of an HTML page using the
<style> element.
9. Inline Styles: Apply styles directly to individual HTML elements using the style
attribute.
Syntax:
selector {
property: value;
another-property: another-value;
}
3. Backgrounds:
Theory:
CSS 2
2. Image Backgrounds: The background-image property allows you to place an image
as the background.
5. Size Control: With background-size , you can scale the size of background images.
8. Shorthand Property: The background property is a shorthand for all the background
properties.
Example:
div {
background: yellow url('image.jpg') no-repeat center center / cover;
}
1. Color Formats: Colors can be defined in various ways including named colors,
HEX, RGB, RGBA, HSL, and HSLA.
2. Transparency with RGBA & HSLA: RGBA and HSLA allow for defining colors with
alpha transparency.
5. currentColor Keyword: Refers to the current color value of an element, useful for
properties like border-color .
CSS 3
6. Web Safe Colors: A collection of colors that display consistently across web
browsers and devices.
7. System Colors: Colors derived from a user's operating system or browser settings.
8. Contrast: Ensuring text colors contrast well with background colors is crucial for
readability.
9. Consistency: Using consistent colors enhances the user experience and brand
recognition.
Example:
p {
color: rgba(255, 0, 0, 0.5);
}
5. Manipulating Texts:
Theory:
4. Spacing: line-height and letter-spacing control the space between lines and
characters.
Example:
CSS 4
p {
text-align: justify;
text-transform: capitalize;
text-shadow: 2px 2px #FF0000;
}
6. Fonts:
Theory:
1. Font Families: font-family defines which font should be used, with fallback
options.
2. Font Size: font-size determines how large the text will appear.
4. Font Style: font-style specifies if the text should be rendered normally, in italics, or
oblique.
9. Font Stretch: font-stretch allows for condensed or expanded faces of a font family.
Example:
body {
font: italic bold 16px/1.5 "Arial", sans-serif;
}
1. Border Styles: border-style defines the style of the border (solid, dashed, dotted,
etc.).
CSS 5
2. Border Width: border-width sets the thickness of the border.
4. Individual Borders: Set styles for individual borders using border-top , border-
right , etc.
7. Box Sizing: box-sizing controls the sizing properties (like width and height ) of an
element.
8. Outline: The outline property is similar to border but doesn't affect layout.
Example:
div {
border: 3px solid #333;
border-radius: 10px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
}
1. Margin: Defines space outside the element, pushing other elements away.
2. Padding: Defines space inside the border, between the content and the border.
3. Collapsing Margins: Adjacent vertical margins can collapse into a single margin.
5. Shorthand Properties: margin and padding can set values for all sides at once.
CSS 6
9. Percentage Values: Margins and padding can be set using percentages, based on
the parent element's width.
Example:
div {
margin: 20px 15px;
padding: 10px 5px;
}
9. Lists:
Theory:
2. List Style Image: list-style-image uses an image as the list item marker.
type: none .
6. Nested Lists: Lists can be nested inside other lists, each potentially having its own
style.
7. Ordered vs. Unordered: <ol> is an ordered list with numbers, while <ul> is
unordered with bullets.
8. Custom Counters: With CSS counters, you can create custom numbering for
ordered lists.
9. Vertical Spacing: Control space between list items using margin and padding .
Example:
ul {
list-style-type: square;
}
li.special {
CSS 7
list-style-image: url('special-marker.jpg');
}
1. Evolution: CSS2 was a revision of the original specification, while CSS3 introduced
modularization.
3. New Features: CSS3 brought new features like rounded corners, shadows,
gradients, transitions, and animations.
11. Animations:
Theory:
CSS 8
5. Delay: animation-delay sets a delay before the animation starts.
8. Fill Mode: animation-fill-mode controls the values applied by the animation outside
the time it's executing.
Example:
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
div {
animation: fadeIn 2s ease-in-out 1s forwards;
}
12. Tool-Tips:
Theory:
2. Content Property: Use the content property to set the tooltip's text.
3. Visibility: Typically, tooltips are hidden by default and displayed on hover or focus.
7. Custom Styling: Tooltips can be styled with any combination of CSS properties.
CSS 9
Example:
[data-tooltip]:hover:after {
content: attr(data-tooltip);
position: absolute;
background-color: #333;
color: #fff;
padding: 5px;
border-radius: 5px;
top: 25px;
left: 50%;
transform: translateX(-50%);
}
4. Filters: The filter property applies graphical effects like blurring or color shifting.
5. Object Fit: object-fit specifies how an image should fit within its box.
9. Caption Styling: Style image captions distinctively using various CSS properties.
Example:
img.rounded {
border-radius: 50%;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
filter: grayscale(50%);
}
14. Variables:
CSS 10
Theory:
1. Definition: Use the - syntax to define a variable, often in the :root selector for
global scope.
5. Dynamic Changes: Variables allow for dynamic theme changes using JavaScript.
9. Browser Support: Modern browsers support CSS variables, but older ones might
not.
Example:
:root {
--primary-color: #4CAF50;
}
button {
background-color: var(--primary-color);
}
4. Wrapping: flex-wrap controls if items should wrap onto multiple lines or columns.
CSS 11
5. Alignment: justify-content , align-items , and align-content control alignment of flex
items.
6. Ordering: The order property on flex items can control their visual order.
7. Growing & Shrinking: flex-grow and flex-shrink define how items grow or shrink
relative to each other.
8. Flex Basis: flex-basis sets the default size of an item before space distribution.
9. Shorthand: The flex property is a shorthand for flex-grow , flex-shrink , and flex-
basis .
Example:
.container {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.item {
flex: 1 1 auto;
}
2. Breakpoints: Determine points where the website's content will respond to provide
the user with the best possible layout.
4. Logical Operators: Use and , not , and only to create more complex media
queries.
5. Mobile First: A design strategy where mobile styles are default, and desktop styles
are added via media queries.
CSS 12
6. Viewport Meta Tag: Essential for responsive design, ensuring the page scales
correctly on different devices.
8. Performance: Avoid overly complex media queries that can decrease performance.
9. Testing: Always test responsive designs on actual devices and screen sizes.
Example:
3. Starts With: [attr^=value] matches elements whose attribute starts with the
specified value.
4. Ends With: [attr$=value] matches elements whose attribute ends with the
specified value.
8. Use Cases: Useful for styling elements based on data attributes or URI schemes.
Example:
CSS 13
* {
box-sizing: border-box;
}
a[href^="https://"] {
color: green;
}
1. Types: Gradients can be linear (straight line) or radial (radiate from a center
point).
3. Direction: For linear gradients, define the direction using angles or keywords.
4. Shape & Size: For radial gradients, control the shape (circle or ellipse) and size.
5. Fallback: Provide a solid color as a fallback for browsers that don't support
gradients.
6. Use Cases: Gradients can be backgrounds, image overlays, or used with text.
Example:
div {
background: linear-gradient(45deg, red, yellow);
}
CSS 14
2. Interaction: :hover , :focus , and :active target user interaction states.
4. Form States: :valid , :invalid , :required , and :optional target form element
validation states.
7. Full-page Styling: :root represents the highest-level parent element, useful for
defining CSS variables.
8. Case-insensitivity: Use :is() and :where() for more flexible and case-insensitive
matching.
Example:
a:hover {
color: red;
}
p:nth-child(odd) {
background-color: lightgray;
}
2. Content Insertion: ::before and ::after insert content before or after an element's
content.
3. Styling Lines: ::first-line and ::first-letter target the first line or letter of block
elements.
4. Content Property: Always use the content property with ::before and ::after .
CSS 15
5. Decorative Uses: Pseudo-elements are often used for decorative purposes, like
custom bullets or underlines.
9. Specificity: Pseudo-elements have lower specificity than classes but higher than
element selectors.
Example:
p::first-line {
font-weight: bold;
}
div::after {
content: "";
display: table;
clear: both;
}
CSS 16
functionality.
7. Performance: Bootstrap is optimized for performance but can be heavy if many
unused components are included.
8. Browser Compatibility: Bootstrap ensures consistent rendering across different
browsers.
9. Community: A large community supports Bootstrap, leading to many plugins,
themes, and resources.
Example:
1. Purpose: Ensure websites look and function well on all devices, from desktops to
mobiles.
2. Fluid Grids: Use relative units like percentages instead of fixed units like pixels.
6. Mobile First: Design for mobile devices first and then scale up for larger screens.
7. Testing: Use device emulators and real devices to test responsive designs.
9. Frameworks: Many CSS frameworks, like Bootstrap, come with built-in responsive
design features.
Example:
CSS 17
}
}
CSS 18