W3-Container or W3-Panel

M2-R5.1 · Chapter 5: CSS Framework · 2 min read

1.W3-Container Class

  • The w3-container class is a general-purpose layout wrapper that adds padding and helps structure your page content neatly.
  • It’s the most commonly used class in W3.CSS layouts.
  • It adds a 16px left and right padding to any HTML element.
  • The w3-container provides equality for all HTML container elements:


  • Common margins
  • Common paddings
  • Common alignments
  • Common fonts
  • Common colors

Syntax:

<div class="w3-container w3-light-grey">
    <h2>Welcome to Skilldotpy</h2> 
    <p>This is inside a W3 container.</p>
</div>

2.W3-Panel Class

  • The w3-panel class is used to create small, highlighted blocks of content (like notices, messages, or alerts).
  • The w3-panel class adds a 16px top and bottom margin and a 16px left and right padding to any HTML element.
  • It automatically adds margins around the element (unlike w3-container) and is ideal for standalone messages or info boxes.

Syntax- 

<div class="w3-panel w3-green">
  <p> Successfully Submitted!</p>
</div>

Example Comparing Both ( Only For lab work)

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
</head>
<body class="w3-padding">

<h2 class="w3-center">Difference Between w3-container and w3-panel</h2>


<div class="w3-container w3-light-blue">
  <h3>W3-CONTAINER</h3>
  <p>This adds padding inside the box. Used for main content areas.</p>
</div>


<div class="w3-panel w3-pale-green w3-border w3-round">
  <h3>W3-PANEL</h3>
  <p>This adds margin outside the box. Used for alerts or notices.</p>
</div>

</body>
</html>