You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
CSS — Cascading Style Sheets — is the language that controls how HTML elements look on screen. While HTML defines the structure and content of a web page, CSS defines its presentation — colours, fonts, spacing, layout, animations, and more. Without CSS, every website would look like a plain text document.
CSS is a declarative, rule-based language. You write rules that describe how specific HTML elements should be styled:
h1 {
color: navy;
font-size: 2rem;
text-align: center;
}
This rule says: "Make all <h1> elements navy, 2rem in size, and centred."
There are three ways to include CSS in your HTML document:
Create a separate .css file and link it from the HTML <head>:
<head>
<link rel="stylesheet" href="styles.css">
</head>
/* styles.css */
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
}
Embed CSS directly in the HTML <head> using a <style> element:
<head>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
}
</style>
</head>
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.