CSS Basics
CSS Basics
Class Selector: .classname { ... } (selects all elements with class classname)
2. Properties: CSS properties define how elements should be styled. Here are some common
categories and properties:
Layout Properties
Clear: Specifies what elements can float beside the cleared element.
Typography Properties
Font-family: Specifies the font of the text.
Background Properties
Flexbox Properties
Flex-wrap: Controls whether flex items should wrap onto multiple lines.
Grid Properties
Transition: Allows property changes in CSS values to occur smoothly over a specified duration.
Animation: Allows you to animate transitions from one CSS style to another.
Media Queries
@media: Used to apply styles based on the viewport size or device characteristics.
css
VerifyRunCopy code
2 body {
3 background-color: lightblue;
4 }
5}
CSS Variables
css
VerifyRunCopy code
1:root {
2 --main-color: #3498db;
3}
4.element {
5 color: var(--main-color);
6}
Conclusion
CSS is a powerful tool for web design, allowing for extensive customization and control over the
appearance of web pages. Understanding these properties and how to use them effectively can greatly
enhance the user experience and visual appeal of a website.
You
css compelete properties notes and styles with syntax and example
BLACKBOXAI
Certainly! Below is a comprehensive guide to CSS properties, including their syntax, examples, and
common use cases. This guide is organized by categories for easier reference.
1. Text Properties
a. Font Properties
font-family
Example:
css
VerifyRunCopy code
1p {
3}
font-size
css
VerifyRunCopy code
1h1 {
2 font-size: 24px;
3}
font-weight
Example:
css
VerifyRunCopy code
1strong {
2 font-weight: bold;
3}
font-style
Example:
css
VerifyRunCopy code
1em {
2 font-style: italic;
3}
line-height
Example:
css
VerifyRunCopy code
1p {
2 line-height: 1.5;
3}
text-align
Example:
css
VerifyRunCopy code
1h2 {
2 text-align: center;
3}
text-decoration
Example:
css
VerifyRunCopy code
1a {
2 text-decoration: underline;
3}
text-transform
Example:
css
VerifyRunCopy code
1h3 {
2 text-transform: uppercase;
3}
color
Example:
css
VerifyRunCopy code
1p {
2 color: #333;
3}
a. Dimensions
width
Example:
css
VerifyRunCopy code
1div {
2 width: 50%;
3}
height
Example:
css
VerifyRunCopy code
1div {
2 height: 200px;
3}
padding
Example:
css
VerifyRunCopy code
1div {
3}
margin
Example:
css
VerifyRunCopy code
1div {
3}
border
Example:
css
VerifyRunCopy code
1div {
3}
3. Background Properties
background-color
Example:
css
VerifyRunCopy code
1body {
2 background-color: #f0f0f0;
3}
background-image
Syntax: background-image: url('image.jpg');
Example:
css
VerifyRunCopy code
1div {
2 background-image: url('background.jpg');
3}
background-repeat
Example:
css
VerifyRunCopy code
1div {
2 background-repeat: no-repeat;
3}
background-position
Syntax: background-position: x y;
Example:
css
VerifyRunCopy code
1div {
3}
background-size
Example:
css
VerifyRunCopy code
1div {
2 background-size: cover;
3}
4. Positioning Properties
position
Example:
css
VerifyRunCopy code
1div {
2 position: relative;
3 top: 10px;
4 left: 20px;
5}
Example:
css
VerifyRunCopy code
1div {
2 position: absolute;
3 top: 50px;
4 left: 100px;
5}
5. Flexbox Properties
display: flex
Example:
css
VerifyRunCopy code
1.container {
2 display: flex;
3}
flex-direction
Example:
css
VerifyRunCopy code
1.container {
2 flex-direction: column;
3}
justify-content
Example:
css
VerifyRunCopy code
1.container {
2 justify-content: space-between;
3}
align-items
Example:
css
VerifyRunCopy code
1.container {
2 align-items: center;
3}
6. Grid Properties
display: grid
Syntax: display: grid;
Example:
css
VerifyRunCopy code
1.grid-container {
2 display: grid;
3}
grid-template-columns
Example:
css
VerifyRunCopy code
1.grid-container {
3}
grid-template-rows
Example:
css
VerifyRunCopy code
1.grid-container {
3}
transition
Example:
css
VerifyRunCopy code
1div {
3}
animation
Example:
css
VerifyRunCopy code
1@keyframes example {
3 to {background-color: yellow;}
4}
5div {
7}
8. Media Queries
@media
Example:
css
VerifyRunCopy code
2 body {
3 background-color: lightblue;
4 }
5}
9. CSS Variables
Custom Properties
css
VerifyRunCopy code
1:root {
2 --main-color: #3498db;
3}
4.element {
5 color: var(--main-color);
6}
Conclusion
This guide provides a detailed overview of CSS properties, their syntax, and examples. Mastering these
properties will enable you to create visually appealing and responsive web designs. ### 10. List
Properties
list-style
Example:
css
VerifyRunCopy code
1ul {
3}
list-style-type
Example:
css
VerifyRunCopy code
1ol {
2 list-style-type: decimal;
3}
list-style-position
Example:
css
VerifyRunCopy code
1ul {
2 list-style-position: outside;
3}
border-collapse
Example:
css
VerifyRunCopy code
1table {
2 border-collapse: collapse;
3}
border-spacing
Example:
css
VerifyRunCopy code
1table {
2 border-spacing: 10px;
3}
table-layout
Example:
css
VerifyRunCopy code
1table {
2 table-layout: fixed;
3}
overflow
Example:
css
VerifyRunCopy code
1div {
2 overflow: hidden;
3}
overflow-x
Example:
css
VerifyRunCopy code
1div {
2 overflow-x: scroll;
3}
overflow-y
Example:
css
VerifyRunCopy code
1div {
2 overflow-y: auto;
3}
13. Cursor Properties
cursor
Example:
css
VerifyRunCopy code
1button {
2 cursor: pointer;
3}
visibility
Example:
css
VerifyRunCopy code
1.hidden {
2 visibility: hidden;
3}
filter
Example:
css
VerifyRunCopy code
1img {
2 filter: grayscale(100%);
3}
Example:
css
VerifyRunCopy code
1div {
2 border-radius: 10px;
3}
clip-path
Example:
css
VerifyRunCopy code
1div {
2 clip-path: circle(50%);
3}
transition-timing-function
Example:
css
VerifyRunCopy code
1div {
3}
z-index
Example:
css
VerifyRunCopy code
1.overlay {
2 position: absolute;
3 z-index: 10;
4}
Conclusion
This extended guide covers additional CSS properties, providing syntax and examples for each.
Understanding these properties will further enhance your ability to create sophisticated and responsive
web designs. ### 19. Animation Keyframes
@keyframes
Example:
css
VerifyRunCopy code
1@keyframes fadeIn {
2 from { opacity: 0; }
3 to { opacity: 1; }
4}
5div {
7}
object-fit
Example:
css
VerifyRunCopy code
1img {
2 object-fit: cover;
3 width: 100%;
4 height: 200px;
5}
text-shadow
Example:
css
VerifyRunCopy code
1h1 {
3}
box-shadow
Example:
css
VerifyRunCopy code
1div {
3}
gap
Example:
css
VerifyRunCopy code
1.grid-container {
2 display: grid;
3 gap: 20px;
4}
column-count
Example:
css
VerifyRunCopy code
1.multi-column {
2 column-count: 3;
3}
column-gap
Example:
css
VerifyRunCopy code
1.multi-column {
2 column-gap: 15px;
3}
writing-mode
Example:
css
VerifyRunCopy code
1p {
2 writing-mode: vertical-rl;
3}
26. Text Overflow Properties
text-overflow
Example:
css
VerifyRunCopy code
1.truncate {
2 white-space: nowrap;
3 overflow: hidden;
4 text-overflow: ellipsis;
5}
appearance
Example:
css
VerifyRunCopy code
1button {
2 appearance: none;
3}
filter
Example:
css
VerifyRunCopy code
1img {
2 filter: brightness(80%);
3}
scroll-snap-type
Example:
css
VerifyRunCopy code
1.scroll-container {
2 scroll-snap-type: x mandatory;
3}
scroll-snap-align
Example:
css
VerifyRunCopy code
1.scroll-item {
2 scroll-snap-align: start;
3}
shape-outside
Example:
css
VerifyRunCopy code
1img {
2 float: left;
3 shape-outside: circle(50%);
4}
Conclusion
This comprehensive guide includes additional CSS properties, their syntax, and examples, further
enhancing your understanding of CSS. Mastery of these properties will allow you to create more dynamic
and visually appealing web designs. ### 31. Grid Auto Flow Property
grid-auto-flow
Example:
css
VerifyRunCopy code
1.grid-container {
2 grid-auto-flow: dense;
3}
resize
Example:
css
VerifyRunCopy code
1textarea {
2 resize: both;
3}
align-content
Example:
css
VerifyRunCopy code
1.flex-container {
2 align-content: space-between;
3}
34. Align Self Property
align-self
Example:
css
VerifyRunCopy code
1.item {
2 align-self: center;
3}
object-position
Syntax: object-position: x y;
Example:
css
VerifyRunCopy code
1img {
3}
text-justify
Example:
css
VerifyRunCopy code
1p {
2 text-justify: inter-word;
3}
word-break
Syntax: word-break: normal | break-all | keep-all;
Example:
css
VerifyRunCopy code
1p {
2 word-break: break-all;
3}
overflow-wrap
Example:
css
VerifyRunCopy code
1p {
2 overflow-wrap: break-word;
3}
column-rule
Example:
css
VerifyRunCopy code
1.multi-column {
3}
text-emphasis
Example:
css
VerifyRunCopy code
1.emphasized {
3}
grid-template-areas
Example:
css
VerifyRunCopy code
1.grid-container {
2 grid-template-areas:
3 "header header"
4 "sidebar content";
5}
backdrop-filter
Example:
css
VerifyRunCopy code
1.overlay {
2 backdrop-filter: blur(5px);
3}
scroll-behavior
Example:
css
VerifyRunCopy code
1html {
2 scroll-behavior: smooth;
3}
appearance
Example:
css
VerifyRunCopy code
1input {
2 appearance: none;
3}
text-overflow
Example:
css
VerifyRunCopy code
1.truncate {
2 white-space: nowrap;
3 overflow: hidden;
4 text-overflow: ellipsis;
5}
shape-outside
Example:
css
VerifyRunCopy code
1img {
2 float: left;
3 shape-outside: circle(50%);
4}
content
Example:
css
VerifyRunCopy code
1.quote::before {
2 content: '"';
3}
grid-column
Example:
css
VerifyRunCopy code
1.item {
2 grid-column: 1 / 3;
3}
grid-row
Example:
css
VerifyRunCopy code
1.item {
2 grid-row: 2 / 4;
3}
text-orientation
Example:
css
VerifyRunCopy code
1p {
2 text-orientation: upright;
3}
list-style-position
Example:
css
VerifyRunCopy code
1ul {
2 list-style-position: inside;
3}
outline
Example:
css
VerifyRunCopy code
1div {
Conclusion
This extensive guide covers a wide range of CSS properties, their syntax, and examples, providing a
thorough understanding of how to utilize CSS effectively in web design. Mastery of these properties will
empower you to create sophisticated, responsive, and visually appealing web pages. ### 51. Filter
Effects
filter
Example:
css
VerifyRunCopy code
1img {
2 filter: blur(5px);
3}
text-decoration-color
Example:
css
VerifyRunCopy code
1a {
2 text-decoration-color: red;
3}
text-decoration-line
Example:
css
VerifyRunCopy code
1p {
2 text-decoration-line: underline;
3}
text-decoration-style
Example:
css
VerifyRunCopy code
1h2 {
3}
column-fill
Example:
css
VerifyRunCopy code
1.multi-column {
2 column-fill: balance;
3}
grid-template-rows
Example:
css
VerifyRunCopy code
1.grid-container {
3}
grid-template-columns
Syntax: grid-template-columns: size;
Example:
css
VerifyRunCopy code
1.grid-container {
3}
text-stroke
Example:
css
VerifyRunCopy code
1h1 {
3}
animation-delay
Example:
css
VerifyRunCopy code
1.fade-in {
3 animation-delay: 1s;
4}
animation-iteration-count
css
VerifyRunCopy code
1.bounce {
3}
animation-direction
Example:
css
VerifyRunCopy code
1.slide {
3}
animation-fill-mode
Example:
css
VerifyRunCopy code
1.fade {
3}
animation-play-state
Example:
css
VerifyRunCopy code
1.paused {
2 animation-play-state: paused;
3}
overflow-anchor
Example:
css
VerifyRunCopy code
1.container {
2 overflow-anchor: none;
3}
scroll-snap-align
Example:
css
VerifyRunCopy code
1.snap-item {
2 scroll-snap-align: start;
3}
scroll-snap-type
Example:
css
VerifyRunCopy code
1.scroll-container {
2 scroll-snap-type: y mandatory;
3}
Example:
css
VerifyRunCopy code
1.content {
2 overflow: hidden;
3}
text-overflow
Example:
css
VerifyRunCopy code
1.truncate {
2 white-space: nowrap;
3 overflow: hidden;
4 text-overflow: ellipsis;
5}
shape-outside
Example:
css
VerifyRunCopy code
1img {
2 float: left;
3 shape-outside: circle(50%);
4}
content
Example:
css
VerifyRunCopy code
1.quote::before {
2 content: '"';
3}
grid-column
Example:
css
VerifyRunCopy code
1.item {
2 grid-column: 1 / 3;
3}
grid-row
Example:
css
VerifyRunCopy code
1.item {
2 grid-row: 2 / 4;
3}
Example:
css
VerifyRunCopy code
1p {
2 text-orientation: upright;
3}
list-style-position
Example:
css
VerifyRunCopy code
1ul {
2 list-style-position: inside;
3}
outline
Example:
css
VerifyRunCopy code
1div {
3}
filter
Syntax: filter: none | blur(px) | brightness(%) | contrast(%) | drop-shadow(px px px
color);
Example:
css
VerifyRunCopy code
1img {
2 filter: blur(5px);
3}
text-decoration-color
Example:
css
VerifyRunCopy code
1a {
2 text-decoration-color: red;
3}
text-decoration-line
Example:
css
VerifyRunCopy code
1p {
2 text-decoration-line: underline;
3}
text-decoration-style
Example:
css
VerifyRunCopy code
1h2 {
3}
column-fill
Example:
css
VerifyRunCopy code
1.multi-column {
2 column-fill: balance;
3}
grid-template-rows
Example:
css
VerifyRunCopy code
1.grid-container {
3}
grid-template-columns
Example:
css
VerifyRunCopy code
1.grid-container {
text-stroke
Example:
css
VerifyRunCopy code
1h1 {
3}
animation-delay
Example:
css
VerifyRunCopy code
1.fade-in {
3 animation-delay: 1s;
4}
animation-iteration-count
Example:
css
VerifyRunCopy code
1.bounce {
animation-direction
Example:
css
VerifyRunCopy code
1.slide {
3}
animation-fill-mode
Example:
css
VerifyRunCopy code
1.fade {
3}
animation-play-state
Example:
css
VerifyRunCopy code
1.paused {
2 animation-play-state: paused;
3}
Example:
css
VerifyRunCopy code
1.container {
2 overflow-anchor: none;
3}
scroll-snap-align
Example:
css
VerifyRunCopy code
1.snap-item {
2 scroll-snap-align: start;
3}
scroll-snap-type
Example:
css
VerifyRunCopy code
1.scroll-container {
2 scroll-snap-type: y mandatory;
3}
overflow
css
VerifyRunCopy code
1.content {
2 overflow: hidden;
3}
text-overflow
Example:
css
VerifyRunCopy code
1.truncate {
2 white-space: nowrap;
3 overflow: hidden;
4 text-overflow: ellipsis;
5}
shape-outside
Example:
css
VerifyRunCopy code
1img {
2 float: left;
3 shape-outside: circle(50%);
4}
content
Syntax: content: "text" | url('image.png') | attr(attribute);
Example:
css
VerifyRunCopy code
1.quote::before {
2 content: '"';
3}
grid-column
Example:
css
VerifyRunCopy code
1.item {
2 grid-column: 1 / 3;
3}
grid-row
Example:
css
VerifyRunCopy code
1.item {
2 grid-row: 2 / 4;
3}
text-orientation
Example:
css
VerifyRunCopy code
1p {
2 text-orientation: upright;
3}
list-style-position
Example:
css
VerifyRunCopy code
1ul {
2 list-style-position: inside;
3}
Syntax:
css
VerifyRunCopy code
Example:
css
VerifyRunCopy code
1div {
3}
2. Outline Width
Syntax:
css
VerifyRunCopy code
css
VerifyRunCopy code
1button {
2 outline-width: 3px;
3}
3. Outline Style
Syntax:
css
VerifyRunCopy code
1outline-style: none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset;
Example:
css
VerifyRunCopy code
1input {
2 outline-style: dashed;
3}
4. Outline Color
Syntax:
css
VerifyRunCopy code
Example:
css
VerifyRunCopy code
1a {
2 outline-color: blue;
3}
5. Outline Offset
Syntax:
css
VerifyRunCopy code
1outline-offset: length;
Example:
css
VerifyRunCopy code
1div {
4}
Complete Example
css
VerifyRunCopy code
1.button {
4}