Tuesday, June 7, 2022
HomeWordPress DevelopmentThe way to stop lengthy phrases from breaking my div ?

The way to stop lengthy phrases from breaking my div ?


Enhance Article

Save Article

Like Article

Cascading Style Sheets fondly known as CSS, is a merely designed language supposed to simplify the method of creating net pages presentable. CSS lets you apply types to net pages. Extra importantly, CSS allows you to do that unbiased of the HTML that makes up every net web page.
CSS is simple to study and perceive, but it surely offers highly effective management over the presentation of an HTML doc.

On this article, we are going to learn to stop lengthy phrases from breaking my HTML div. 

We will stop one lengthy phrase with out breaking your HTML div aspect by numerous methods. 

Strategy: 

  • We’re utilizing an HTML div aspect by which we can be displaying the HTML paragraph aspect.
  • We use word-break delicate hyphens &shy; and <wbr> tags on the paragraph aspect to indicate the output.

Instance 1: On this instance, we are able to make use of sentimental hyphen( ­). A delicate hyphen will stop lengthy phrases from breaking the HTML div aspect.  

HTML

<!DOCTYPE html>

<html>

<head>

    <model>

        p{

            coloration:black;

            text-align:middle;

        }

        div{

            border:2px strong black;

            width:200px;

            margin-left:20px;

            background-color:lightgrey;

        }

    </model>

</head>

  

<physique>

    <h1 model="coloration:inexperienced">GeeksforGeeks</h1>

    <div>

          

<p>A­computerscienceprotalforgeeks</p>

  

    </div>

</physique>

</html>

Output:

 

Instance 2: On this method, we are able to make use of the phrase break <wbr> tag. It’s used to specify the place in a textual content it might be positive so as to add a line break.

HTML

<!DOCTYPE html>

<html>

  

<head>

    <model>

        p{

            coloration:black;

            text-align:middle;

        }

        div{

            border:2px strong black;

            width:200px;

            margin-left:20px;

            background-color:lightgrey;

        }

    </model>

</head>

  

<physique>

    <h1 model="coloration:inexperienced">GeeksforGeeks</h1>

    <div>

          

<p>A<wbr>computerscienceprotalforgeeks</p>

  

    </div>

</physique>

</html>

Output:

 

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments