HTML

HTML CSS

In HTML, you can add CSS (Cascading Style Sheets) to control the presentation and layout of your web pages. CSS allows you to style elements like text, colors, spacing, and positioning. You can include CSS in your HTML document in several ways:

  1. Inline CSS:
    You can apply CSS directly to individual HTML elements using the “style” attribute. For example:
<p style="color: blue; font-size: 16px;">A paragraph with inline CSS.</p>
HTML
  1. Internal CSS:
    You can include CSS within the “<head>”section of your HTML document using the”<style>” tag. The styles inside this tag will apply to the entire document.
<!DOCTYPE html>
<html>
<head>
    <title>My Web Page</title>
    <style>
        p {
            color: blue;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <p>A paragraph with internal CSS.</p>
</body>
</html>
HTML
  1. External CSS:
    You can create a separate CSS file with a “.css” extension and link it to your HTML document using the “<link>” tag. This method allows you to keep your CSS code separate from your HTML code, making it easier to manage and maintain.

Create a file named “styles.css”:

/* styles.css */
p {
    color: blue;
    font-size: 16px;
}
HTML

Add a link to your HTML content from the external CSS file:

<!DOCTYPE html>
<html>
<head>
    <title>My Web Page</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <p>A paragraph with external CSS.</p>
</body>
</html>   
HTML

Using external CSS is the recommended approach for larger projects, as it promotes code organization and reusability.

By – Tutvid

Remember that CSS selectors allow you to target specific elements, classes, or IDs, giving you fine-grained control over your styles. This is just a basic introduction to using CSS in HTML. As you delve deeper into web development, you’ll discover more advanced techniques and features available in CSS.

also read: HTML Color

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *