Skip to content

Instantly share code, notes, and snippets.

@chearon
Created October 24, 2021 02:25
Show Gist options
  • Save chearon/3323251fb70d527f2311118e11d3b87c to your computer and use it in GitHub Desktop.
Save chearon/3323251fb70d527f2311118e11d3b87c to your computer and use it in GitHub Desktop.
Behavior of browsers when padding is on break characters

Padding and breaks

Padding is on a break and contains text

Padding-left Padding-right
Browsers do All browsers assign padding-left to the word after it All browsers assign padding-right to the word before it, but Safari does not consider the padding when measuring for fit and neither does Chrome when it’s **not **the last break
I do After Before

Padding is on a break and doesn’t contain text

Also contained by padding-left Also contained by padding-right No container
Browsers do Safari and Chrome assign to the word after; Firefox assigns to the word before Safari assigns to the word after, Chrome assigns to the word before but does not include when measuring for fit; Firefox assigns to the word before Safari assigns the padding to the word after; others assign to the word before. Chrome doesn’t include the padding when measuring for fit if it’s the last break.
I do After Before Before

Break is inside the padding’s span

The break is the first break
Browsers do Chrome assigns the padding to the word after the break; Firefox assigns the padding to the word before the break; Safari renders like Firefox at first sometimes, then renders as Chrome after you click!
I do Before
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment