Additional Resources
- https://web.dev/learn/css/
- https://www.w3schools.com/Css/
- https://www.codecademy.com/learn/learn-css
Hey there! In this post, I’m going to give you a brief introduction to CSS, which stands for Cascading Style Sheets. CSS is a language that lets you style and format your web pages, such as changing the colors, fonts, layouts, and animations. CSS is very powerful and flexible, and it can make your web pages look more attractive and professional.
To use CSS, you need to link it to your HTML document, which is the structure of your web page. There are three ways to do this: inline, internal, and external. Inline means you write the CSS code directly in the HTML element that you want to style, using the style attribute. For example:
Internal means you write the CSS code in the head section of your HTML document, using the style tag. For example:
External means you write the CSS code in a separate file with the .css extension, and then link it to your HTML document using the link tag. For example:.
The external method is the most recommended one, because it keeps your HTML and CSS code separate and organized, and it allows you to reuse the same CSS file for multiple web pages.
The basic syntax of CSS is:
selector {
property: value;
}
The selector is the HTML element that you want to style, such as p, h1, div, etc. The property is the aspect of the element that you want to change, such as color, font-size, width, etc. The value is the specific setting that you want to apply to the property, such as blue, 20px, 50%, etc. You can use multiple properties and values for each selector, separated by semicolons.
For example:
p {
color: green;
font-weight: bold;
text-align: center;
}
This CSS code will make all the paragraphs in your web page green, bold, and centered.
You can also use more specific selectors to target certain elements based on their attributes, classes, ids, or relationships. For example:
p.intro {
color: purple;
}
This CSS code will only affect the paragraphs that have the class attribute set to “intro”.
main {
background-color: yellow;
}
This CSS code will only affect the element that has the id attribute set to “main”.
div > p {
margin: 10px;
}
This CSS code will only affect the paragraphs that are direct children of a div element.
There are many more selectors and properties that you can use in CSS to create amazing web pages. I hope this post gave you a good overview of what CSS is and how to use it. Thanks for reading!