What is CSS?
CSS (Cascading Style Sheets) is used alongside HTML to style and format elements in the browser. The file extension is .css and the MIME type is text/css.
The example below defines a CSS rule to render a red 200px square.
.square {
background: #f00;
height: 200px;
width: 200px;
}CSS Usage Example in HTML
The following HTML demonstrates how to use embedded CSS to apply styles to elements.
<!DOCTYPE html>
<html>
<head>
<title>CSS Example</title>
<style>
.square {
background: #f00;
height: 200px;
width: 200px;
}
</style>
</head>
<body>
<div class="square"></div>
</body>
</html>What is a CSS ID Selector?
What is a CSS ID Selector?
#header {
background: #333;
color: #fff;
height: 40px;
width: 100%;
}What is a CSS Class Selector?
What is a CSS Class Selector?
.post {
background: #fff;
box-shadow: 0 0 2px;
color: #333;
height: 600px;
padding: 10px;
width: 400px;
}Why Minify CSS?
Minifying CSS removes spaces, comments, and line breaks to reduce file size and improve load times.
.post{background:#fff;box-shadow:0 0 2px;color:#333;height:600px;padding:10px;width:400px}CSS Formatter / Beautifier / Minifier FAQs
What is a CSS Formatter?
Can I minify CSS?
Is CSS safe to use?
What file extension does CSS use?
.css extension.