digital dreamscapes - by somnath pan
Welcome to our CSS Basics tutorial! In this tutorial, we'll cover the fundamental CSS concepts and properties to style your web page.
This CSS tutorial assumes that you have a basic knowledge and understanding of html,if you're new to html,consider exploring our html-basics tutorial,before proceeding to this CSS tutorial
CSS (Cascading Style Sheets) is a styling language used to control the layout and appearance of web pages.
CSS selectors target HTML elements, and properties define the styles applied to those elements.
<style>
h1 {
color: blue;
}
</style>
Use the color
property for text color and background-color
for element backgrounds.
<style>
h1 {
color: blue;
background-color: yellow;
}
</style>
Use the font-family
property to set font types and font-size
for text size.
<style>
h1 {
font-family: Arial;
font-size: 36px;
}
</style>
Use the display
property for layout and position
for element positioning.
<style>
.container {
display: flex;
position: relative;
}
</style>
Use the margin
property to add space around elements and padding
for space between elements and their content.
<style>
.container {
margin: 20px;
padding: 20px;
}
</style>
Use the border
property to add borders to elements and outline
for a border outside the element.
<style>
.container {
border: 1px solid black;
outline: 1px solid red;
}
</style>
Congratulations! You've learned the basic CSS concepts and properties. Practice building your own web page using this tutorial as a reference. In the next tutorial, we'll explore CSS layouts and responsive design.