Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS break-after Property

Posted in CSS Tutorial
Updated on Oct 02, 2024
By Mari Selvan
👁️ 14 - Views
⏳ 4 mins
💬 1 Comment
CSS break-after Property

Photo Credit to CodeToFun

🙋 Introduction

The break-after property in CSS is used to control the behavior of page, column, or region breaks after an element. It is particularly useful in paged media, multi-column layouts, and other situations where content needs to be broken up across multiple pages, columns, or regions.

This property helps in managing the flow of content in a more controlled and predictable manner.

💡 Syntax

The syntax for the break-after property is simple. You apply it to an element and specify the type of break you want to occur after that element.

Syntax
Copied
Copy To Clipboard
element {
  break-after: value;
}

🎛️ Default Value

The default value of the break-after property is auto, meaning that no explicit break is applied, and the break behavior is determined by the browser's default settings.

🏠 Property Values

ValueDescription
autoDefault value. Automatic page/column/region break behavior.
alwaysAlways force a page/column/region break after the element.
avoidAvoid a page/column/region break after the element.
leftForce a page/column/region break after the element, so that the next page/column/region is formatted as a left page.
rightForce a page/column/region break after the element, so that the next page/column/region is formatted as a right page.
pageForce a page break after the element.
columnForce a column break after the element.
regionForce a region break after the element.

📄 Example

In this example, we'll apply the break-after property to a div element to ensure a page break after the element in a paged media context.

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 break-after Example</title>
  <style>
    .page-break {
      break-after: page;
    }
  </style>
</head>
<body>
  <h1>Content Before Page Break</h1>
  <div class="page-break">
    This content will be followed by a page break.
  </div>
  <h1>Content After Page Break</h1>
  <p>This content will appear on a new page.</p>
</body>
</html>

🖥️ Browser Compatibility

The break-after property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

🎉 Conclusion

The break-after property is a valuable tool for managing content flow in complex layouts, especially when dealing with paged media, multi-column layouts, or regions. By using this property, you can create more controlled and predictable layouts, ensuring that content breaks occur exactly where you want them. Experiment with different values to see how this property can enhance the readability and presentation of your web projects.

👨‍💻 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