How to Wrap text in Html

To enclose text in HTML, we need to adhere to the following procedures. By following these steps, users can effortlessly enclose any text meant for display on a webpage.

To begin, the initial step involves entering the HTML code into a text editor or accessing an already existing HTML file in the text editor where text wrapping is desired.

Example

<!Doctype Html>

<Html>   

<Head>    

<Title>   

Wrap the text

</Title>

</Head>

<Body> 

 Hello User 

 Your are at C# Tutorial Site .

If we want to wrap the text in Html, then we have to follow the steps which are given on this page. 

</Body> 

</Html>

Step 2: Next, we need to employ the word-wrap attribute. To do this, position the cursor between the opening and closing head tags right after the title tag. Subsequently, specify a class and include the <div> tag within the <style> tag, following the example provided below.

Example

<Head>    

<Title>   

Wrap the text

</Title>

<style>

div {

  width: 100px; 

  border: 2px solid red;

}

div.class_name {

  word-wrap: normal;

}

</style>

</Head>

Step 3: Next, it is necessary to establish the class that will be used to encapsulate the desired text.

Example

<div class="a">Any text which we want to wrap </div>

Step 4: Finally, it is necessary to save the file and execute it in the web browser.

Example

<!Doctype Html>

<Html>   

<Head>    

<Title>   

Wrap the text

</Title>

<style>

div {

  width: 100px; 

  border: 2px solid red;

}

div.a {

  word-wrap: normal;

}

div.b {

  word-wrap: break-word;

}

</style>

</Head>

<Body> 

 Hello User 

 <div class="a">Your are at C# TutorialSite.Ifwe want to wrap the text in Html then we have to follow the steps which are given in this page. </div> <br>

   <div class="b">Your are at C# TutorialSite.Ifwe want to wrap the text in Html then we have to follow the steps which are given in this page. </div>

</Body> 

</Html>

The displayed result of the HTML code above can be observed in the screenshot below:

Input Required

This code uses input(). Please provide values below: