How to Make a Diagonal Section Divider with CSS
To make a slanted section divider, add clip-path: polygon() to the section and raise only its bottom-right corner. You don't need an image or a pseudo-element. However, cutting alone shows the page background in the cut-off area, so you need to overlap the next section underneath. I also checked how to add spacing so text on the slanted edge is not clipped, and how to write the angle so it stays the same when the screen width changes.
The test environment was Ubuntu 24.04, Node.js 22.23.4, Playwright 1.63.0, and Chromium 153. I opened HTML and CSS pages with Playwright, recorded the values from getComputedStyle(), and took screenshots to record where the colors changed. I did not test Firefox, Safari, real smartphones, or screens where a scrollbar takes up width.
- 1. Cut the bottom edge diagonally with polygon() in clip-path
- 2. Overlap the next section upward by the cut height
- 3. Text on the slanted edge is clipped, so add bottom padding
- 4. If you write the cut height in %, the angle changes with the content
- 5. Keep the angle the same when the screen width changes
- 6. Supported browsers
Cut the bottom edge diagonally with polygon() in clip-path
The HTML is just two sections placed one after another. Add the slant class to the upper section.
<section class="slant">…</section>
<section>…</section>
You only need one line of clip-path.
/* Cut the bottom edge of the section on a diagonal that rises to the right */
.slant {
clip-path: polygon(0 0, 100% 0, 100% calc(100% - 60px), 0 100%);
}
clip-path displays only the inside of the shape you specify. polygon() takes the vertices of a polygon as "x y" pairs. The four vertices in this example are the top-left, the top-right, 60px above the bottom-right, and the bottom-left. Only the bottom-right corner is raised by 60px, so the bottom edge becomes a diagonal line that rises from the bottom-left to the top-right.
I tested this on an 800px-wide screen. At the left edge, the light blue of the upper section continued to the bottom edge. At the right edge, it ended 60px above the bottom edge. However, the triangle in the bottom-right corner (10px from the right edge and 10px above the bottom edge) was white. In the cut-off part, the page background (white) behind it was visible.

Overlap the next section upward by the cut height
To show the next section's color in the cut-off area, give the next section a negative margin-top equal to the cut height (60px) so it overlaps upward. Because the overlap also moves the next section's text upward, increase padding-top by the same amount.
/* Let the background of the next section show in the cut-off area */
.slant {
position: relative;
z-index: 1;
}
.slant + section {
margin-top: -60px;
padding-top: calc(60px + 32px);
}
The triangle in the earlier test now showed the color of the next section (rgb(238, 250, 253)). The top edge of the next section's heading is 32px below the bottom edge of the upper section, so the upper section does not hide it.
I added position: relative and z-index: 1 in case the next section has position: relative. When I removed them and tested without position on the next section, the upper section was displayed without being hidden. However, when I gave the next section position: relative, the slanted part of the upper section was hidden behind the next section's background (in all three places I checked, the color was the next section's). When I gave the upper section position: relative and z-index: 1, it was drawn in front even though the next section had position: relative.
Text on the slanted edge is clipped, so add bottom padding
clip-path also clips the text inside the section. I tested by right-aligning the last paragraph of a section, and the text at the bottom right disappeared partway along the slanted edge. Compared with the same paragraph without clip-path, 1,038 of the 2,386 text pixels had changed color.

Increasing padding-bottom by the cut height fixes this.
/* Add bottom padding equal to the cut height */
.slant {
--slant: 60px;
clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--slant)), 0 100%);
padding-bottom: calc(var(--slant) + 32px);
}
After this change, the number of text pixels that changed color was 0. If you keep the cut height in the custom property
--slant, you can use the same value for both clip-path and the padding.
If you write the cut height in %, the angle changes with the content
The vertical position in polygon() can also be written in %. For example, if you use 100% 80%, the bottom-right corner is at 80% of the section's height.
/* Write the cut height in % (proportional to the section's height) */
.slant-percent {
clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%);
}
With this approach, the cut height depends on the section's height. On an 800px-wide screen, the slanted part was 27px tall for a section that was 137px high. After I added six paragraphs and the section grew to 341px, the slanted part became 68px. If each section has a different amount of text, the angles of the dividers will also differ.
Keep the angle the same when the screen width changes
If you fix the height, as in --slant: 60px, the angle does not depend on how much content the section has. However, the angle changes when the screen width changes. Measuring the angle of the slanted edge on screen, it was about 9.0 degrees at 375px wide, about 4.2 degrees at 800px wide, and about 2.6 degrees at 1280px wide. The slope is steep on narrow screens and gentle on wide ones.
To keep the angle constant, make the cut height "screen width × tan(angle)." The CSS tan() function takes an angle and returns its tangent, and it can be multiplied by a length inside calc(). Putting the approach together so far gives the following.
/* Keep the slant at 5deg, avoid clipping text, and make the next section fit below */
:root {
--slant: calc(100vw * tan(5deg));
}
.slant {
position: relative;
z-index: 1;
clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--slant)), 0 100%);
padding-bottom: calc(var(--slant) + 32px);
}
.slant + section {
margin-top: calc(-1 * var(--slant));
padding-top: calc(var(--slant) + 32px);
}
--slant is written on :root so that the next section (.slant + section) can use the same value. Custom properties are inherited from parent to child, so if you write it on .slant, the next sibling section cannot read it.
At 375px wide, the computed clip-path value was polygon(0px 0px, 100% 0px, 100% calc(100% - 32.8083px), 0px 100%), so the cut height was 32.8px. At 800px it was 70.0px, and at 1280px it was 112.0px. The angle measured from the slanted edge on screen was between 4.89 and 4.96 degrees, so it was about 5 degrees at every width. At every width, the bottom edge of the paragraph was above the slanted edge, and the next section's heading was below the bottom edge of the upper section.

100vw is the width of the screen (the viewport), not the width of the section. So with this approach, the angle is 5 degrees only when the section spans the full width of the screen. On an 800px-wide screen, I placed the two sections in a 600px-wide box. The cut height stayed at 70.0px, calculated from the screen width, and the angle of the slanted edge was about 6.6 degrees.
Supported browsers
I checked the features used in this article against MDN's compatibility data (@mdn/browser-compat-data 8.1.8).
| Feature | Chrome | Firefox | Safari |
|---|---|---|---|
clip-path (unprefixed) |
55 | 3.5 | 9.1 |
polygon() |
37 | 54 | 10.1 |
tan() |
111 | 108 | 15.4 |
The values in the table are for each feature separately. Firefox 3.5 is the value for the clip-path property itself. Cutting with polygon() is supported from 54. The last CSS in this article uses tan(), so it works as is only from Chrome 111, Firefox 108, and Safari 15.4.





