I have a problem with HTML, for example, I have a container, inside the container I have several elements and among them there is an element <p>
, the problem is that there comes a point in which the text inside <p>
is too much and causes the text or the <p>
comes out of the container.
This is because I established a width
del 20%
, and it needs to have that width, my question is, how do I make it so that instead of continuing the text in length, when it is at the limit of the container, it does a line break?
This would be my HTML file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="main.css">
<title>Document</title>
</head>
<body>
<div class="container">
<div class="column">
<h2>Tituloooooooooooo</h2>
<p class="price">500$</p>
<p>aaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd</p>
</div>
<div class="column">
<h2>Tituloooooooooooo</h2>
<p class="price">500$</p>
<p class="">aaaaaaaaaaaaaaaaa</p>
</div>
</div>
</body>
</html>
And this my CSS file:
.container {
display: flex;
justify-content: flex-start;
flex-flow: wrap;
border: 1px solid black;
padding: 10px;
}
.column {
border: 1px solid black;
padding: 10px;
margin: 5px 12px 25px 12px;
width: 20%;
}
This would be the image of how the result is displayed:
For the word to be "cut" and generate a line break you could use:
Option 1:
overflow-wrap
Setting
overlfow-word
equal tobreak-word
we get:show
Option 2:
word break
Setting
word-break
equal tobreak-all
we get:show