Margins and padding (w3-margin, w3-padding).

Margins and padding (w3-margin, w3-padding).

Margin and Padding Classes in the W3.CSS Framework Component Library The margin and padding class properties are used to control or manage the spacing around an HTML webpage object element and on the inner side of the object. The W3.CSS Framework Classes provide a collection of utility classes for applying margin and padding attributes to web developers. This allows web developers to make immediate adjustments or alignment to the layout of any website object element without writing custom CSS web script source code.

Margins and padding (w3-margin, w3-padding)

Margin Classes in the W3.CSS Framework.

In HTML design, webpage object margins help control and manage the outer space of an element. This creates a gap between the border of the current webpage object element and the surrounding element area. Web developers find several margin and utility classes in the W3.CSS framework to easily adjust webpage object margins.

Margin class details in the W3.CSS framework.

  • .w3-margin – This HTML design adds margin space to all sides of an element in a webpage website object.
  • .w3-margin-top – This HTML design adds margin space to the top of an element in a webpage website object.
  • .w3-margin-right – This HTML design adds margin space to the right side of an element in a webpage website object.
  • .w3-margin-bottom – This HTML design adds margin space to the bottom of an element in a webpage website object.
  • .w3-margin-left – This HTML design adds margin space to the left side of an element in a webpage website object.
  • .w3-margin-{size} – This HTML design provides different W3-margin margin class size choices for web developer specific web object spacing in webpage website object. For example, w3-margin-small, w3-margin-medium, w3-margin-large, etc. can be applied to existing web page object as per requirement.

W3.CSS framework common margin class size options.

  • .w3-margin-small – This adds a small margin (typically 8px) space to an HTML webpage website object element.
  • .w3-margin-medium – This adds a medium margin (typically 16px) space to an HTML webpage website object element.
  • .w3-margin-large – This adds a large margin (typically 32px) space to an HTML webpage website object element.
  • .w3-margin-xlarge – Adds an extra large margin (typically 64px) to an HTML webpage website object element.
  • .w3-margin-xxlarge – Adds a double extra large margin (typically 128px) to an HTML webpage website object element.
  • .w3-margin-auto – Automatically adjusts the margins for an HTML webpage website object element. Specifically, it is used with the w3-center margin class property.

Example of the W3.CSS framework margin class.

<!DOCTYPE html>

<html lang=”en”>

<head>

<meta charset=”UTF-8″>

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”>

<title>Let’s Explore W3.CSS framework margin class attributes </title>

</head>

<body>

<!– it displays Element margin from all object sides –>

<div class=”w3-margin”>

<p>This html text object element have margin from all sides.</p>

</div>

<!– it displays Element margin from Top direction –>

<div class=”w3-margin-top”>

<p>This html text object element have margin from top side.</p>

</div>

<!– it displays Element margin from Bottom direction –>

<div class=”w3-margin-bottom”>

<p>This html text object element have margin from bottom side.</p>

</div>

<!– it displays Element margin from Small direction –>

<div class=”w3-margin-small”>

<p>This html text object element have margin from small margin side.</p>

</div>

<!– it displays Element margin from Large Margin direction –>

<div class=”w3-margin-large”>

<p>This html text object element have margin from large margin.</p>

</div>

<!– it displays Element margin from Auto Margin centring side –>

<div class=”w3-margin-auto w3-center”>

<p>This html text object element have margin from cantered with auto margins side.</p>

</div>

</body>

</html>

Here in this W3.CSS framework margin class example.

  • The first div block has the .w3-margin class, which adds margins to all sides of the current object.
  • Similarly, the second and third div tags display margin classes to add top and bottom margin space to the block element.
  • The fourth and fifth div block elements display small and large margin classes, respectively.
  • Finally, the div block displays center class object adjustments with the .w3-margin-auto and .w3-center classes.

Padding Class Attributes in the W3.CSS Framework.

The Padding class in the W3.CSS Framework Component Library helps manage the space between web content and the border of an HTML webpage object element. The W3.CSS Framework provides a variety of utility classes for padding space, which can be applied to any webpage object element as needed.

Details of the W3.CSS Framework Padding Class.

  • .w3-padding – This HTML design adds padding space to all sides of a webpage website object element.
  • .w3-padding-top – This HTML design adds padding space to the top position of a webpage website object element.
  • .w3-padding-right – This HTML design adds padding space to the right side of a webpage website object element.
  • .w3-padding-bottom – This HTML design adds padding space to the bottom of a webpage website object element.
  • .w3-padding-left – This HTML design adds padding space to the left of a webpage website object element.
  • .w3-padding-{size} – Web developers can apply class attributes to different padding size options, such as w3-padding-small, w3-padding-medium, w3-padding-large, etc., for special padding size effects.

W3.CSS Framework Padding Class Common size options.

  • .w3-padding-small – This helps us display small padding sizes, typically 8px pixels, on HTML design webpage website object elements.
  • .w3-padding-medium – This HTML design helps webpage website object elements display a medium padding size, typically 16px pixels.
  • .w3-padding-large – This HTML design helps webpage website object elements display a large padding size, typically 32px pixels.
  • .w3-padding-xlarge – This HTML design helps webpage website object elements display an extra-large padding size, typically 64px pixels.
  • .w3-padding-xxlarge – This HTML design helps webpage website object elements display a double extra-large padding size, typically 128px pixels.

Example of W3.CSS Framework padding class.

<!DOCTYPE html>

<html lang=”en”>

<head>

<meta charset=”UTF-8″>

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”>

<title>Let’s Explore W3.CSS framework Padding class attributes </title>

</head>

<body>

<!– it displays Element Padding from all sides –>

<div class=”w3-padding”>

<p>This html text object element has padding applied from all sides.</p>

</div>

<!– it displays Element with Top Padding –>

<div class=”w3-padding-top”>

<p>This html text object element has padding applied from the top direction.</p>

</div>

<!– it display Element with Bottom Padding –>

<div class=”w3-padding-bottom”>

<p>This html text object element has padding applied from the bottom direction.</p>

</div>

<!– it display Element with Small Padding –>

<div class=”w3-padding-small”>

<p>This html text object element has padding applied from small padding inside direction.</p>

</div>

<!– it display Element with Large Padding –>

<div class=”w3-padding-large”>

<p>This html text object element has padding applied from large padding inside direction.</p>

</div>

</body>

</html>

Here’s the W3.CSS Framework padding class example.

  • In this example, the first div block defines a .w3-padding space, which adds padding to all sides of the current webpage object.
  • Similarly, the second and third div tag block elements display padding classes for top and bottom padding space. Similarly, the fourth and fifth div block elements can display small and large padding class attributes and effects.

Group example of W3.CSS framework margin and padding.

Web developers can add and display margin and padding classes to control and manage the space between object elements within and outside an HTML webpage. These classes help create a clear, properly organized webpage layout or well-structured design.

Example of margin and padding group in W3.CSS framework.

<!DOCTYPE html>

<html lang=”en”>

<head>

<meta charset=”UTF-8″>

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”>

<title>Let’s Explore W3.CSS framework group Margin and Padding class attributes </title>

</head>

<body>

<!– it display Element with Margin and Padding effect –>

<div class=”w3-margin w3-padding”>

<p>This html text object element with group margin and padding effect.</p>

</div>

<!– it display Element with Top Margin and Small Padding attributes–>

<div class=”w3-margin-top w3-padding-small”>

<p>This HTML text object element with top margin and small padding effect.</p>

</div>

<!– it display Element with Bottom Margin and Large Padding attributes–>

<div class=”w3-margin-bottom w3-padding-large”>

<p>This HTML text object element with bottom margin and large padding effect.</p>

</div>

</body>

</html>

Here’s an example of a margin and padding group in W3.CSS.

  • In this example, both all-side margin and padding effects have been applied to the first div block using the .w3-margin and .w3-padding classes.
  • Similarly, the top margin (w3-margin-top) and small padding (w3-padding-small) class effect attributes have been applied to the second div block.
  • In the same sequence, bottom margin (w3-margin-bottom) and large padding (w3-padding-large) classes have been added to the third div block.