Curriculum
Course: CSS Advanced
Login

Curriculum

CSS Advanced

CSS Rounded Corners

0/1

CSS Border Images

0/1

CSS Color Keywords

0/1

CSS Text Effects

0/1

CSS 2D Transforms

0/1

CSS 3D Transforms

0/1

CSS Transitions

0/1

CSS Animations

0/1

CSS Tooltip

0/1

CSS Style Images

0/1

CSS Image Reflection

0/1

CSS Masking

0/1

CSS Buttons

0/1

CSS Multiple Columns

0/1

CSS User Interface

0/1

CSS Box Sizing

0/1

CSS Media Queries

0/1
Text lesson

CSS Text Effects

CSS Text Overflow, Word Wrap, Line Breaking Rules, and Writing Modes

In this section, you’ll explore the following properties:

  • text-overflow
  • word-wrap
  • word-break
  • writing-mode

CSS Text Overflow

The CSS text-overflow property determines how content that overflows and is not visible should be indicated to the user.

It can be clipped:

IMG_3652

or it can be displayed as an ellipsis (…):

IMG_3653

The CSS code appears as follows:

Example 

p.test1 {
  white-space: nowrap;
  width: 200px;
  border: 1px solid #000000;
  overflow: hidden;
  text-overflow: clip;
}

p.test2 {
  white-space: nowrap;
  width: 200px;
  border: 1px solid #000000;
  overflow: hidden;
  text-overflow: ellipsis;
}

 

Below is an example demonstrating how overflowed content can be displayed when hovering over the element:

Example 

div.test:hover {
  overflow: visible;
}

CSS Word Wrapping

The CSS word-wrap property enables long words to break and wrap onto the next line when necessary.

If a word exceeds the available space, it extends beyond the boundary.

IMG_3654

The word-wrap property enables text wrapping even if it entails breaking a word in the middle.

IMG_3655

Here is the CSS code:

Example 

Allow long words to break and wrap onto the next line.

{
  word-wrap: break-word;
}

CSS Word Breaking

The CSS word-break property determines the rules for breaking lines.

IMG_3656

Here is the CSS code:

 

Example 

p.test1 {
  word-break: keep-all;
}

p.test2 {
  word-break: break-all;
}

CSS Writing Mode

The CSS writing-mode property determines the orientation of text lines, specifying whether they are laid out horizontally or vertically.

IMG_3657 2

Below, you’ll find an example showcasing various writing modes.

Example 

p.test1 {
  writing-mode: horizontal-tb;
}

span.test2 {
  writing-mode: vertical-rl;
}

p.test2 {
  writing-mode: vertical-rl;
}