For me it is duplicate subject, but however, Here is probably the best solution to make it going with svg.
Answer with 3rd votes from: https://stackoverflow.com/questions/16056591/font-scaling-based-on-width-of-container?answertab=votes#tab-top
DEMO:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.resizeme {
resize: both;
margin: 0;
padding: 0;
height: 200px;
min-width: 100px;
max-width: 500px;
background-color: lightblue;
overflow: hidden;
}
<!-- language: lang-html -->
<div class="resizeme">
<svg
width="100%"
height="100%"
viewBox="0 0 500 200"
preserveAspectRatio="xMinYMin meet"
>
<foreignObject width="100%" height="100%" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="background-color:lightgreen;">
<h1>heading</h1>
<p>Resize the blue box.</p>
</div>
</foreignObject>
</svg>
</div>
<!-- end snippet -->
## Solution with SVG:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.resizeme {
resize: both;
margin: 0;
padding: 0;
height: 75px;
width: 500px;
background-color: lightblue;
overflow: hidden;
}
<!-- language: lang-html -->
<div class="resizeme">
<svg
width="100%"
height="100%"
viewBox="0 0 500 75"
preserveAspectRatio="xMinYMid meet"
style="background-color:green"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<text
x="0"
y="75"
font-size="75"
fill="black"
>█Resize This█</text>
</svg>
</div>
<!-- end snippet -->
## Solution with SVG and text-wrapping using `foreignObject`:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.resizeme {
resize: both;
margin: 0;
padding: 0;
height: 200px;
width: 500px;
background-color: lightblue;
overflow: hidden;
}
<!-- language: lang-html -->
<div class="resizeme">
<svg
width="100%"
height="100%"
viewBox="0 0 500 200"
preserveAspectRatio="xMinYMin meet"
>
<foreignObject width="100%" height="100%" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="background-color:lightgreen;">
<h1>heading</h1>
<p>Resize the blue box.</p>
</div>
</foreignObject>
</svg>
</div>
<!-- end snippet -->