If you are using a long word without any break in between then the text might extend beyond the allocated area and push out giving a bad experience to end-users.
Use the word-wrap property and set it to break-word, additionally a fixed-width needs to be specified.
For example, below is some sample text in a Div with a long word without a break. Notice, how it goes outside the allocated area (width = 300px).
This is a Div. I am going to show how a looooooooooooooooooooooooooonggggggggggggggggggggggggg text without any breaks will look like.
Now let us look at the same example, but using the word-wrap property (word-wrap:break-word). Notice how neatly the text is wrapped and aligned.
Here is the code (a fixed width is important here) -<div style="background:lightgray;width:300px;word-wrap:break-word">
This is a Div. I am going to show how a looooooooooooooooooooooooooonggggggggggggggggggggggggg text without any breaks will look like.
</div>
Output:
This is a Div. I am going to show how a looooooooooooooooooooooooooonggggggggggggggggggggggggg text without any breaks will look like.
More Posts related to Html,
- Comprehensive 256 Ascii code table with Html Hex IBM Microsoft Key
- HTML5 HELLO WORLD Example
- What is the doctype for HTML5?
- The author stylesheet specified in tag script is too long - document contains 21759 bytes whereas the limit is 10000 bytes
- W3 : character data is not allowed here html validation error
- HTML, HTML5. CSS, CSS3 Color Codes 2020
- Obsolete marquee element alternatives html5
- Create HTML button that looks like a href hyperlink
- All directional arrows codes for HTML
- Adding Sub Headings to Bootstrap Header tags
- Hyperlink in html (anchor tag) without a underline
- Align html element at the center of page vertically and horizontally
- How to remove old 404 pages ulrs from Google crawler
- How to set background color in HTML page?
- Default speed of Marquee tag : SCROLLAMOUNT
- W3 HTML validator warning Unable to Determine Parse Mode
- Get HTML table td, tr or th inner content value with id or name attribute
- reCaptcha Verification expired. Check the checkbox again
- How to word wrap in HTML
- Base 64 Index, Character and Binary Table
- Fibonacci series from 1 to 500 table
- How to make a div tag clickable
- Remove Html head and body tags from ckeditor source
- remove div vertical scroll
- Chessboard with pieces using pure HTML and CSS
More Posts:
- The package must have at least one . separator [Android Studio] - Android-Studio
- Make div element draggable using jQuery - jQuery
- How to make a Android button act as a toggle button - Android
- How to Kill service running on port using terminal command - HowTos
- Export aborted because fatal lint error were found - Android
- How to check if Java main thread is alive - Java
- Remove Applications from Startup Mac OS X - Mac-OS-X
- How to Stop Photos App from auto loading when device connected to the Mac - Mac-OS-X
- Custom Toast Android Programming - Android
- CSS: Apply opacity only for div background and not text - CSS
- Resolving DNS_PROBE_FINISHED_NXDOMAIN Google Chrome Error - Google
- How to make div or text in html unselectable using CSS - CSS
- DDMS files not found hprof-conv.exe - Android
- Android Studio : Change FAB icon color : FloatingActionButton - Android-Studio
- [Hibernate] The method buildSessionFactory() from the type Configuration is deprecated - Java