user3422161
user3422161

Reputation: 319

cannot control the width of div and how can I fix it?(html)

Here is html and CSS code:

.d1 {
  display: inline-block;
  font-size: 16pt;
  width: 30px;
  border: 3px solid #73AD21;
}
<div class="d1">
  testingggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
</div>

the text breaks through the width of div even though I have set

display:inline-block

Are there any methods that makes the text within the width of div?

Upvotes: 0

Views: 44

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 190907

Set your CSS to have word-wrap to break-word.

.d1{
display:inline-block;
font-size:16pt;
width:30px;
border: 3px solid #73AD21; 
word-wrap: break-word;
}
<div class="d1">
testingggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
</div>

Upvotes: 3

Related Questions