CSS (Cascading Style Sheets) is a web development language used to describe the presentation of an HTML document when displayed or rendered

Filed under

CSS ("Cascading Style Sheets") is a language (not a programming language) for describing the properties of elements in HTML documents. Commonly, these properties have an impact on the look and/or feel fo the elements, therefore making CSS to be commonly considered a language to describe how an HTML page would look like.

CSS definitions can be contained inside an HTML file, as follows:

<!DOCTYPE html>
<html>
	<head>
		<title>Document</title>
		<style>
			.important {
				font-weight: bold;
			}
			.warning {
				color: red;
			}
		</style>
	</head>
	<body>
		<h1>Sample that uses CSS</h1>
		<p>Welcome to the sample program. <span class="important">Now we are saying that this
		is how things should be done.</span> Before CSS, this was not how things
		<span class="warning">used to be</span>.</p>
	</body>
</html>

Or the definitions can be contained in a separate file, referenced from the HTML file, as follows:

style.css

.important {
	font-weight: bold;
}
.warning {
	color: red;
}

index.html

<!DOCTYPE html>
<html>
	<head>
		<title>Document</title>
		<link rel="stylesheet" type="text/css" href="style.css" />
	</head>
	<body>
		<h1>Sample that uses CSS</h1>
		<p>Welcome to the sample program. <span class="important">Now we are saying that this
		is how things should be done.</span> Before CSS, this was not how things
		<span class="warning">used to be</span>.</p>
	</body>
</html>

Additional information

HTML5

CSS Selectors

Structuring HTML, CSS and Javascript content


Twitter Facebook LinkedIn Youtube Slideshare Github