I have an h3 element of which I don't know its width. Therefore the width is at auto
- the default. But I want the text inside of it to have hyphenation. It is in flex container together with a second element. The flex container has a fixed width. This works in all browsers, except for Safari. There the hyphenation simply doesn't work at all. The text overflows and pushes also the second element out of the wrapper. In Safari it only works when I set the width of the h3 element to a specific value, for example width: 300px
or width: 80%
, but as I already mentioned I can't do that. it also works when I remove the display: flex
, but I also don't want to do that.
Here's a short example to showcase the problem:
.card {
display: flex;
align-items: flex-start;
border: 1px solid #ddd;
width: 200px;
}
h3 {
flex: 1;
background: #ff5604;
hyphens: auto;
-webkit-hyphens: auto;
}
button {
display: inline-block;
}
<html lang="de">
<head>
</head>
<body>
<div class="card">
<h3>Versicherungsmaklerbüro/Versicherungsmaklerinnenbüro</h3>
<button>
Button
</button>
</div>
</body>
</html>
Is there a pure CSS way to make Safari behave?