1

What I mean by this is, in normal CSS, you can assign a class or id to a div, and assign a style to that particular class, which can then be used in multiples areas on the site. Is it possible to do this in w3.css? If I'm making an entire website, with many conatiners having the exact same style, it would get rather tedious to have to copy the same w3.css style into each container. I attached an example below to clarify what I mean.

.cssOnly {
  background-color: yellow;
  color: black;
  border-radius: 4px;
  margin: 16px;
  padding: 16px;
}
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Page Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link href="style.css" rel="stylesheet" type="text/css" />
<script src=""></script>

<body>

  <div class="cssOnly">
    <h1>Using CSS</h1>
    <p>Here I can have 2 divs with the same style by applying a class with a css style assigned to it.</p>
    <p>No need to make two separate styles, I can use the same one!</p>
  </div>

  <div class="cssOnly">
    <h1>Using CSS</h1>
    <p>Here I can have 2 divs with the same style by applying a class with a css style assigned to it.</p>
    <p>No need to make two separate styles, I can use the same one!</p>
  </div>


  <div class="w3-container w3-yellow w3-round w3-margin">
    <h1>Using w3.CSS</h1>
    <p>With w3.css, I have to copy and paste the w3.css styling to each separate div.</p>
    <p>I hope there is a quicker way to style divs with w3!</p>
  </div>

  <div class="w3-container w3-yellow w3-round w3-margin">
    <h1>Using w3.CSS</h1>
    <p>With w3.css, I have to copy and paste the w3.css styling to each separate div.</p>
    <p>I hope there is a quicker way to style divs with w3!</p>
  </div>

</body>

</html>
  • 1
    Honestly w3.css is just as bad of an approach as tailwindcss. What you are trying to do is how it's actually done, except you should try to find a more speaking CSS class name. – connexo Jan 07 '22 at 05:23

0 Answers0