git-scm.com icon indicating copy to clipboard operation
git-scm.com copied to clipboard

CSS word-break property on <code> elements allows line breaks

Open johnpaxton opened this issue 4 years ago • 1 comments

URL for broken page

https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merging

Problem

The code element has its CSS property word-break set to break-all. This permits line breaks within a code element. In the paragraph immediately following the h3 linked to in the URL, the word "hotfix" has a line break between "ho" and "tfix". This happens in several places in this document alone. It may very well affect other documentation throughout the site.

Operating system and browser

Mac OS Monterey 12.4 Firefox 103.0 (64-bit) Also reproduced in Chrome 103.0.5060.134 (Official Build) (arm64)

Steps to reproduce

  1. Go to https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merging
  2. Look at the paragraph below the h3 that says "Basic Merging"
  3. Look at the rendering of the word "hotfix" to see a line break within the word
  4. Look at the rendering of the words "git merge" which have a line break like this: "g\nit merge"

Other details

Per MDN's word-break docs, consider either removing the word-break declaration entirely (which would revert the property's value to normal) or explicitly set word-break's value to normal.

johnpaxton avatar Jul 28 '22 00:07 johnpaxton

Hmm, yeah, I don't see it in my default view, but if I tweak the font size, I can get it to wrap. And indeed, it's ugly.

Looks like it was changed in 2445646d0715d3716bd51633af7ac33ad0c1f493 as part of #1644. The goal there was making the site overall more responsive. I would imagine it could help on super-constrained mobile screens. But breaking in the middle of a word is pretty bad, and the normal setting should allow inter-word breaks. So I'm inclined to just revert that bit of the PR entirely.

peff avatar Jul 29 '22 20:07 peff