How to use CSS in html

Learn how to use CSS in HTML to style your web pages and create beautiful designs with this easy-to-follow example tutorial.

Using CSS in HTML is a great way to style and format your web pages. CSS, which stands for Cascading Style Sheets, allows you to control the appearance of your HTML elements, such as text, images, and layout. In this article, I will show you how to use CSS in HTML to enhance the look and feel of your web pages.

Linking CSS to HTML

To use CSS in HTML, you can link an external CSS file to your HTML document using the <link> tag in the <head> section of your HTML file. Here's an example of how to link an external CSS file:

<head>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head>

Using Inline CSS

You can also use inline CSS by adding the style attribute to an HTML element. This allows you to apply CSS styles directly to individual HTML elements. Here's an example of how to use inline CSS:

<p style="color: blue; font-size: 16px;">This is a paragraph with inline CSS</p>

Using Internal CSS

Another way to use CSS in HTML is by using internal CSS. This involves placing your CSS styles within a <style> tag in the <head> section of your HTML file. Here's an example of how to use internal CSS:

<head>
  <style>
    p {
      color: red;
      font-size: 18px;
    }
  </style>
</head>

These are the basic ways to use CSS in HTML to style your web pages. By linking external CSS files, using inline CSS, or using internal CSS, you can create visually appealing and well-formatted web pages.

h

Answers (0)