Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,845 questions

51,766 answers

573 users

How to wrap a text using CSS and HTML

1 Answer

0 votes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Wrapping Example</title>
<style>
    /* Container styling */
    .wrapper {
        width: 300px;               /* Fixed width to demonstrate wrapping */
        border: 2px solid #333;     /* Border for visibility */
        padding: 10px;
        font-family: Arial, sans-serif;
        
        /* Enable wrapping for long words */
        word-wrap: break-word;      /* Older property */
        overflow-wrap: break-word;  /* Modern property */
        white-space: normal;        /* Allow normal wrapping */
    }
</style>
</head>
<body>

<h2>Text Wrapping Demo</h2>

<div class="wrapper">
    This text will wrap automatically when it reaches the edge of the container.
</div>

<br>

<div class="wrapper">
    ThisIsATextWithoutSpacesThatWillBreakAndWrapToTheNextLineUsingCSS.
</div>

</body>
</html>


<!--
run:

This text will wrap automatically when it 
reaches the edge of the container.

ThisIsATextWithoutSpacesThatWillBreakA
ndWrapToTheNextLineUsingCSS.

-->

 



answered Dec 3, 2025 by avibootz

Related questions

1 answer 259 views
1 answer 201 views
201 views asked Jul 14, 2016 by avibootz
1 answer 216 views
2 answers 307 views
307 views asked Jul 16, 2016 by avibootz
1 answer 616 views
...