TEST
TEST
TEST
Introduction to CSS
What is CSS?
CSS (Cascading Style Sheets) is used to control the look and layout of a web page.
It allows you to separate content from design, making web pages more visually
appealing and easier to manage.
How CSS Works
Styles are added directly within an HTML element using the style attribute.
Example:
html
Copy code
<p style="color: red;">This is a red paragraph.</p>
Internal CSS
Styles are placed within a <style> tag in the <head> section of an HTML document.
Example:
html
Copy code
<style>
p {
color: red;
}
</style>
External CSS
Styles are defined in a separate .css file linked to the HTML document using the
<link> tag.
Example:
html
Copy code
<link rel="stylesheet" href="styles.css">
styles.css:
css
Copy code
p {
color: red;
}
CSS Selectors
Basic Selectors
Space outside the border of an element. Controlled with the margin property.
css
Copy code
div {
margin: 20px;
}
Padding
Space inside the border of an element. Controlled with the padding property.
css
Copy code
div {
padding: 15px;
}
Shorthand Properties
Use shorthand for margins and padding with one, two, three, or four values.
css
Copy code
margin: 10px 20px; /* top/bottom | left/right */
padding: 5px 10px 15px; /* top | right/left | bottom */
CSS Layout
Display Property
div {
animation: example 2s infinite;
}
Responsive Design
Media Queries
CSS (Cascading Style Sheets) is used to control the look and layout of a web page.
It allows you to separate content from design, making web pages more visually
appealing and easier to manage.
How CSS Works
Styles are added directly within an HTML element using the style attribute.
Example:
html
Copy code
<p style="color: red;">This is a red paragraph.</p>
Internal CSS
Styles are placed within a <style> tag in the <head> section of an HTML document.
Example:
html
Copy code
<style>
p {
color: red;
}
</style>
External CSS
Styles are defined in a separate .css file linked to the HTML document using the
<link> tag.
Example:
html
Copy code
<link rel="stylesheet" href="styles.css">
styles.css:
css
Copy code
p {
color: red;
}
CSS Selectors
Basic Selectors
Space outside the border of an element. Controlled with the margin property.
css
Copy code
div {
margin: 20px;
}
Padding
Space inside the border of an element. Controlled with the padding property.
css
Copy code
div {
padding: 15px;
}
Shorthand Properties
Use shorthand for margins and padding with one, two, three, or four values.
css
Copy code
margin: 10px 20px; /* top/bottom | left/right */
padding: 5px 10px 15px; /* top | right/left | bottom */
CSS Layout
Display Property