How can I surround a multiline text in html/css with a box? Currently, I have this:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Badge Element</title>
<style>
.container {
width: 200px;
border: 1px solid #ccc;
padding: 10px;
text-align: right;
}
.badge {
display: inline-block;
padding: 5px 10px;
background-color: #007BFF;
color: white;
border-radius: 12px;
word-break: break-word;
box-sizing: border-box;
white-space: normal;
}
</style>
</head>
<body>
<div class="container">
<span class="badge">
ThisIsAVeryLongWord ShortWord
</span>
</div>
</body>
</html>
The problem is that there is space on the left-hand side. I don’t want the badge to fill the entire container. How can I do that?