What is CSS and way to write
What is CSS
CSS stands for cascading style sheet.CSS is a stylesheet language used to style and design HTML element on web pages.
Cascading Means that when multiple CSS rules apply to same HTML element,the browser follows a set of rules to decide which style should be applied.
There are three ways to add CSS to HTML:
- Inline CSS
- Internal CSS
- External CSS
Let understand these three ways:
- Inline CSS
In this way CSS is written directly inside a HTML element.
HTML:
<p style="color:brown">Welcome to CSS</p>
Browser Preview:
- Internal CSS
In this way CSS is Written inside <style> tag inside <head> tag in the HTML document.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p{
color:green;
}
</style>
</head>
<body>
<p>Welcome to CSS</p>
</body>
</html>
Browser Preview:
- External CSS
CSS is written in a separate .css file and connected to HTML.
- Create a new file
style.css
- Use <link> tag to connect that css file
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
HTML:
<body>
<p>Welcome to CSS</p>
</body>
In style.css file
p{
color:green
}
Browser Preview:

Comments
Join the discussionNo comments yet. Be the first to comment.