Day 31: logical border properties

posted on

It’s time to get me up to speed with modern CSS. There’s so much new in CSS that I know too little about. To change that I’ve started #100DaysOfMoreOrLessModernCSS. Why more or less modern CSS? Because some topics will be about cutting-edge features, while other stuff has been around for quite a while already, but I just have little to no experience with it.


Just like for margin or padding, there are also logical property variations for border properties.

Originally there were 4 shorthand properties we could use for defining borders.

And we could do the same for each physical side (top, right, bottom, left).

Now there are a couple of more properties:

border-block

div {
  border-block: solid;
}
border-block
div {
  border-block: 20px solid aqua;
}
border-block
div {
  border-block-color: green;
  border-block-width: 10px 20px;
  border-block-style: dashed dotted;
}
border-block

We can do the same for each individual side (block-start and block-end).

div {
  border-block-start: 2em solid red;
}
border-block-start
div {
  border-block-end-color: blue;
  border-block-end-width: 1rem;
  border-block-end-style: dashed;
}
border-block-end

border-inline

div {
  border-inline: solid;
}
border-inline
div {
  border-inline: 20px solid aqua;
}
border-inline
div {
  border-inline-color: green;
  border-inline-width: 10px 20px;
  border-inline-style: dashed dotted;
}
border-inline

We can do the same for each individual side (inline-start and inline-end).

div {
  border-inline-start: 2em solid red;
}
<div>
  border-inline-start
</div>
border-inline-start
<div dir="rtl">
  border-inline-start
</div>
border-inline-start
div {
  border-inline-end-color: blue;
  border-inline-end-width: 1rem;
  border-inline-end-style: dashed;
}
border-inline-end

See on CodePen

Further reading

Do you want to learn even more awesome CSS?

I'm running a workshop with my friends at Smashing Magazine in which I introduce you to the most useful modern features in CSS and show how you can implement them today in your code base to improve scalability, maintainability, and productivity.

Learn more about the workshop!

Overview: 100 Days Of More Or Less Modern CSS