The style tag
The style
tag allows you to write CSS directly inside the HTML page. Note that inside the style
tag we write, observing the syntax of the CSS language (selectors, curly braces, and so on).
This tag should be placed inside the head
tag, but this is not necessary - the style
tag can be placed inside the body
tag and it will work.
The style
tag should not be overused - instead, you should most often use a separate CSS file.
Example
Let's write CSS inside HTML code using the style
tag:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>This is the title title</title>
<style>
p {
color: red;
}
</style>
</head>
<body>
<h1>This is a header in standard (black) color.</h1>
<p>This is a red paragraph.</p>
</body>
</html>