Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade For Teachers Spaces Get Certified Upgrade For Teachers Spaces
   ❮     
     ❯   

CSS Tutorial

CSS HOMECSS IntroductionCSS SyntaxCSS SelectorsCSS How ToCSS CommentsCSS ErrorsCSS ColorsCSS BackgroundsCSS BordersCSS MarginsCSS PaddingCSS Height/WidthCSS Box ModelCSS OutlineCSS TextCSS FontsCSS IconsCSS LinksCSS ListsCSS TablesCSS DisplayCSS Max-widthCSS PositionCSS Z-indexCSS OverflowCSS FloatCSS Inline-blockCSS AlignCSS CombinatorsCSS Pseudo-classesCSS Pseudo-elementsCSS OpacityCSS Navigation BarsCSS DropdownsCSS Image GalleryCSS Image SpritesCSS Attr SelectorsCSS FormsCSS CountersCSS UnitsCSS InheritanceCSS SpecificityCSS !importantCSS Math FunctionsCSS OptimizationCSS AccessibilityCSS Website Layout

CSS Advanced

CSS Rounded CornersCSS Border ImagesCSS BackgroundsCSS ColorsCSS Color KeywordsCSS GradientsCSS ShadowsCSS Text EffectsCSS Custom FontsCSS 2D TransformsCSS 3D TransformsCSS TransitionsCSS AnimationsCSS TooltipsCSS Image StylingCSS Image ModalCSS Image CenteringCSS Image FiltersCSS Image ShapesCSS object-fitCSS object-positionCSS MaskingCSS ButtonsCSS PaginationCSS Multiple ColumnsCSS User InterfaceCSS VariablesCSS @propertyCSS Box SizingCSS Media QueriesCSS MQ Examples

CSS Flexbox

Flexbox IntroFlex ContainerFlex ItemsFlex Responsive

CSS Grid

Grid IntroGrid ContainerGrid ItemsGrid 12-column LayoutCSS @supports

CSS Responsive

RWD IntroRWD ViewportRWD Grid ViewRWD Media QueriesRWD ImagesRWD VideosRWD FrameworksRWD Templates

CSS SASS

SASS Tutorial

CSS Examples

CSS TemplatesCSS ExamplesCSS EditorCSS SnippetsCSS QuizCSS ExercisesCSS WebsiteCSS SyllabusCSS Study PlanCSS Interview PrepCSS BootcampCSS Certificate

CSS References

CSS ReferenceCSS SelectorsCSS CombinatorsCSS Pseudo-classesCSS Pseudo-elementsCSS At-rulesCSS FunctionsCSS Reference AuralCSS Web Safe FontsCSS AnimatableCSS UnitsCSS PX-EM ConverterCSS ColorsCSS Color ValuesCSS Default ValuesCSS Browser Support

CSSText Effects


CSS Text Effects

CSS has some properties to handle text overflow, word wrapping, line breaking rules and writing modes.

In this chapter you will learn about the following properties:

  • text-overflow - Specifies how to handle overflowed content
  • word-wrap - Allows long words to be able to be broken and wrap onto the next line
  • word-break - Specifies line breaking rules
  • writing-mode - Specifies whether lines of text are laid out horizontally or vertically

CSS text-overflow Property

The CSStext-overflow property specifies how overflowed content that is not displayed should be signaled to the user. It can be clipped or rendered with ellipsis (...).

Both of the following properties are required fortext-overflow to take effect:

Here, the overflowed content is clipped:

This is some long text that will not fit in the box

Here, the overflowed content is rendered with ellipsis (...):

This is some long text that will not fit in the box

The CSS code is as follows:

Example

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

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

The following example shows how you can display the overflowed content when hovering over the element:

Example

p:hover {
  overflow: visible;
}
Try it Yourself »


CSS word-wrap Property

The CSSword-wrap property allows long words to be able to be broken and wrap onto the next line. 

If a word is too long to fit within an area, it expands outside:

This paragraph contains a very long word: thisisaveryveryveryveryveryverylongword. The long word will break and wrap to the next line.

Theword-wrap property allows you to force the text to wrap - even if it means splitting it in the middle of a word:

This paragraph contains a very long word: thisisaveryveryveryveryveryverylongword. The long word will break and wrap to the next line.

The CSS code is as follows:

Example

Allow long words to be able to be broken and wrap onto the next line:

p {
  word-wrap: break-word;
}
Try it Yourself »

CSS word-break Property

The CSSword-break property specifies how words should break when reaching the end of a line.

This property can take one of the following values:

  • normal - This is default. Uses the default line breaking rules of the language
  • break-all - Allows words to be broken at any character to prevent overflow
  • keep-all - Prevents words from breaking

Here, we usenormal:

This paragraph contains some text. This line will-break-at-hyphens.

Here, we usebreak-all:

This paragraph contains some text. The lines will break at any character.

The CSS code is as follows:

Example

p.test1 {
  word-break: normal;
}

p.test2 {
  word-break: break-all;
}
Try it Yourself »

CSS writing-mode Property

The CSSwriting-mode property specifies whether lines of text are laid out horizontally or vertically.

This property can take one of the following values:

  • horizontal-tb - Default. The text flows horizontally from left to right, vertically from top to bottom
  • vertical-rl - The text flows vertically from top to bottom, horizontally from right to left
  • vertical-lr - The text flows vertically from top to bottom, horizontally from left to right

Here is a text with a span element with avertical-rl writing-mode.

The following example shows some different writing modes:

Example

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

span {
  writing-mode: vertical-rl;
}

p.test2 {
  writing-mode: vertical-rl;
}
Try it Yourself »


CSS Text Effect Properties

The following table lists the CSS text effect properties:

PropertyDescription
text-justifySpecifies how justified text should be aligned and spaced
text-overflowSpecifies how overflowed content that is not displayed should be signaled to the user
word-breakSpecifies line breaking rules for non-CJK scripts
word-wrapAllows long words to be able to be broken and wrap onto the next line
writing-modeSpecifies whether lines of text are laid out horizontally or vertically


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2025 Movatter.jp