QP School

Full Version: Apply CSS3 styles to HTML
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Assumed you have an HTML5 document and a separated CSS3 file, the example would be:

HTML part:

<!DOCTYPE html>
<html>
<head>
  <title>Applying Styles to HTML Example</title>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
  <h1>Welcome to My Website</h1>
  <p>This is a paragraph with some text.</p>
</body>
</html>

CSS part:

/* styles.css */
h1 {
  color: blue;
  text-align: center;
}

p {
  font-size: 16px;
}

Explanation:

To apply CSS styles to HTML, we create a separate CSS file (styles.css in this example) and link it to the HTML document using the <link> element. In the CSS file, we define styles for the h1 element to set the text color to blue and center align the text. Additionally, we apply a font size of 16 pixels to all p elements.