Controlling Word Breaks

Description

The word-wrap property controls when to wrap a word.

The allowed values for this property are described as follows.

  • normal - Words are not broken, even when they cannot be fitted into the containing element.
  • break-word - Words are broken to make them fit.

Example

The following code shows the application of the word-wrap property.


<!DOCTYPE HTML>
<html>
<head>
<style>
p  {<!--from w  ww .  ja v a 2 s.c  om-->
    width:150px;
    margin:  15px;
    padding: 5px;
    border: medium double   black;
    background-color: lightgrey;
    float:left;
}

#first {
    word-wrap: break-word;
}

#second  {
    word-wrap: normal;
}
</style>
</head>
<body>
    <p id="first">this is a test.this is a test.this is a test.this is a test.this is a test.
    this is a test.this is a test.this is a test.this is a test.this is a test.</p>
    <p id="second">this is a test.
    this is a test.this is a test.this is a test.this is a test.
    this is a test.this is a test.this is a test.this is a test.
    this is a test.this is a test.this is a test.this is a test.</p>
</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table