Why is hyphenation not working with lang en
Asked Answered
H

0

7

What is wrong with this code that hyphenations don't work for lang="en"?

h1 {
  font-size: 2em;
  hyphens: auto;
}

div {
  max-width:200px;
  background: aqua;
}
<div>
  <h1 lang="en">Kindofverylongheadlineevenbiggerthanimagined</h1>
  <h1 lang="en">Internationalization</h1>
  <h1 lang="de">Kindofverylongheadlineevenbiggerthanimagined</h1>
</div>
Harden answered 12/10, 2021 at 19:3 Comment(9)
Hyphenation rules are language-specific. In HTML, the language is determined by the lang attribute, and browsers will hyphenate only if this attribute is present and the appropriate hyphenation dictionary is available. MDNContraception
If look at this article it says a couple of things: 1. You must specify a language using the lang HTML attribute to guarantee that automatic hyphenation is applied in that language. 2. browsers will hyphenate only if this attribute is present and the appropriate hyphenation dictionary is available 3. It is possible that you are setting correct bounds for your text container.Robbie
Note all the notes regarding browser support on caniuse.com's support listing for the property.Lejeune
@Robbie please don't use code formatting for emphasis or quoting. Use it for code.Lejeune
Wondering why I see the German text hyphenated but not the EnglishCariole
Was just noticing that.Elvieelvin
Duplicate?Contraception
Does this answer your question? Why hyphens don't work with inner <span>?Elvieelvin
I voted duplicate and tried some of the answers there, but they didn't then, and still don't seem to fix the problem. Win/Firefox and Chrome.Elvieelvin

© 2022 - 2024 — McMap. All rights reserved.