×
   ❮     
HTML CSS MySql Javascript SQL PYTHON JAVA C++ C# BOOTSTRAP REACT XML NODEJS ANGULAR DJango Rust Android VUE
     ❯   

HTML css Integration


How to Integrate CSS in HTML?

HTML CSS integration refers to the procedure of combining HTML (Hypertext Markup Language) and CSS (Cascading Style Sheets) to create visually appealing and dependent web pages.

HTML provides the structure and content material of a web site, even as CSS defines the presentation and layout of the content.

CSS (Cascading Style Sheets):

CSS is a style sheet language used to define the presentation, layout, and design of HTML documents.

It allows developers to control the appearance of various elements on a webpage, including fonts, colors, margins, padding, positioning, and more.

CSS rules are applied to HTML elements either inline, embedded within the HTML document, or in an external CSS file.

Inline CSS

Inline CSS refers to styling HTML elements directly within the HTML markup using the style attribute.

Example

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>HTML CSS Integration</title>
</head>

<body style="background-color: #f0f0f0; font-family: Arial, sans-serif;">

  <div style="max-width: 800px; margin: 50px auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);">

    <h1 style="color: #333;">Welcome to HTML CSS Integration</h1>
    <p>This is a basic example of HTML and CSS integration.</p>

    <div style="background-color: #f2f2f2; padding: 10px; border: 1px solid #ccc; border-radius: 3px; margin-top: 20px;">
      <p>This is a styled box.</p>
    </div>

  </div>

</body>

</html>
Try it Yourself »

External CSS File

HTML (index.html) file:

In your head tag add this "<link rel="stylesheet" href="styles.css">"

Create a new file called "style.css" that will contains a css file.

Example

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>HTML CSS Integration</title>
  <link rel="stylesheet" href="styles.css">
</head>

<body>
  <div class="container">

    <h1>Welcome to HTML CSS Integration</h1>
    <p>This is a basic example of HTML and CSS integration.</p>

    <div class="box">
      <p>This is a styled box.</p>
    </div>

  </div>
</body>

</html>
Try it Yourself »

CSS (styles.css) file:

Example

body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}

.container {
max-width: 800px;
margin: 50px auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
color: #333;
}

.box {
background-color: #f2f2f2;
padding: 10px;
border: 1px solid #ccc;
border-radius: 3px;
margin-top: 20px;
}
Try it Yourself »

Hey there! Let's go for Learn fasta then! It is more than just coding; it is to have the superpower that can solve any problem. Through simple and easy-to-grasp examples you will sail through the learning process. In addition, it is not just about coding– you will acquire competencies on how to solve complex problems, analyze data, and come up with efficient solutions. Shall we start this wonderful journey together! learnfasta.com terms of use, Copyright 2025 All Rights Reserved.