Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS padding-block-start Property

Posted in CSS Tutorial
Updated on Oct 07, 2024
By Mari Selvan
👁️ 13 - Views
⏳ 4 mins
💬 1 Comment
CSS padding-block-start Property

Photo Credit to CodeToFun

🙋 Introduction

The padding-block-start property in CSS is part of the logical properties module, which allows developers to set padding in the block start direction of an element. The block start direction is determined by the writing mode of the document; in most cases, it corresponds to the top padding.

This property is particularly useful for creating layouts that are adaptable to different writing modes and languages.

💡 Syntax

The syntax for the padding-block-start property is as follows:

Syntax
Copied
Copy To Clipboard
element {
  padding-block-start: length | percentage | auto | initial | inherit;
}

🎛️ Default Value

The default value of the padding-block-start property is 0, meaning no padding is applied by default.

🏠 Property Values

ValueDescription
lengthA specific value in units such as px, em, or rem.
percentageA percentage relative to the width of the containing block.
autoThe browser calculates the value.
initialThe initial value (usually 0).
inheritThe value is inherited from the parent element.

📄 Example

In this example, we'll apply padding to the block start of a paragraph.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS padding-block-start Example</title>
  <style>
    p {
      padding-block-start: 20px;
      background-color: lightgrey;
    }
  </style>
</head>
<body>
  <h1>Paragraph with Block Start Padding</h1>
  <p>This paragraph has 20px padding at the block start, which corresponds to the top in most left-to-right writing modes.</p>
</body>
</html>

🖥️ Browser Compatibility

The padding-block-start property is widely supported in modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is advisable to check the compatibility with the browsers you aim to support, especially if your audience includes users of older browser versions.

🎉 Conclusion

The padding-block-start property is a valuable tool for web developers looking to create flexible and responsive layouts.

By using logical properties like this one, you can make your designs more adaptable to different writing modes and languages, enhancing the accessibility and usability of your website. Experiment with different values to see how they affect your layout and consider using this property in conjunction with other logical properties for a more consistent design.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy