HTML Styles
- HTML styles are used to format the layout of a web page.
- CSS (Cascading Style Sheets) is used to style HTML and can be used to alter text size and fonts used, add borders and drop shadows, layout your page with columns, and much more
There are three ways to use styles in HTML:
You can add styles directly to an HTML element using the style attribute.
<p style="color: red; font-size: 16px;">This is a paragraph.</p>
You can add styles to the <head>
section of an HTML document using the <style>
tag.
<head>
<style>
p {
color: red;
font-size: 16px;
}
</style>
</head>
<body>
<p>This is a paragraph.</p>
</body>
You can create a separate CSS file and link it to your HTML document using the <link>
tag.
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<p>This is a paragraph.</p>
</body>
CSS can be used to style any HTML element, including headings, paragraphs, links, images, and more. Here is an example of how to style a paragraph using CSS: