How To Wrap Table Cell Content Using CSS ? - GeeksforGeeks
Trang chủ » Html Table Fixed Column Width Not Word Wrap
» How To Wrap Table Cell
Content Using CSS ? - GeeksforGeeks
Có thể bạn quan tâm
Skip to content
- Courses
- DSA to Development
- For Working Professionals
- Data Structure & Algorithm Classes (Live)
- System Design (Live)
- JAVA Backend Development(Live)
- DevOps(Live)
- Data Structures & Algorithms in Python
- For Students
- Interview Preparation Course
- GATE CS & IT 2024
- Data Science (Live)
- Data Structure & Algorithm-Self Paced(C++/JAVA)
- Master Competitive Programming(Live)
- Full Stack Development with React & Node JS(Live)
- For School Students
- CBSE Class 12 Computer Science
- School Guide
- Python Programming Foundation
- All Courses
- Tutorials
- Web Development
- Web Development Roadmap
- Front-End Development
- Back-End Development
- Full Stack Development
- MERN Stack
- MEAN Stack
- PHP Tutorial
- WordPress Tutorial
- Web Development Projects
- Front End Developer Interview Questions
- Learn Web Designing
- Web Development using Python
- Django
- Django Tutorial
- Top Django Projects
- Django Interview Questions
- Flask
- Flask Tutorial
- Python Flask Projects
- Flask Interview Questions
- Postman
- Github
- Web Scrapping in Python
- ML & Data Science
- Machine Learning
- Machine Learning Tutorial
- Maths for ML
- ML Projects
- 100 Days of Machine Learning
- Data Science Tutorial
- Data Science Packages
- Pandas Tutorial
- NumPy Tutorial
- Data Visualization
- Data Visualization with Python
- Data Visualization with R
- Tableau
- Power BI
- Data Analysis
- Data Analysis with Python
- Data Analysis with R
- 100 Days of Data Analytics
- Deep Learning
- NLP Tutorial
- OpenCV Tutorial
- Interview Questions
- Machine Learning Interview Question
- Deep Learning Interview Question
- R Interview Questions
- Data Structures & Algorithms
- DSA for Beginners
- Data Structures
- Arrays
- Matrix
- Strings
- Linked List
- Stack
- Queue
- Tree
- Generic Tree
- Binary Tree
- Binary Search Tree
- AVL Tree
- B Tree
- B+ Tree
- Red Black Tree
- Tree Data Structure Tutorial
- Heap
- Hashing
- Graph
- Set Data Structure
- Map Data Structure
- Advanced Data Structure
- Data Structures Tutorial
- Algorithms
- Analysis of Algorithms
- Searching Algorithms
- Linear Search
- Binary Search
- Searching Algorithms Tutorial
- Sorting Algorithms
- Selection Sort
- Bubble Sort
- Insertion Sort
- Merge Sort
- Quick Sort
- Heap Sort
- Counting Sort
- Radix Sort
- Bucket Sort
- Sorting Algorithms Tutorial
- Greedy Algorithms
- Dynamic Programming
- Graph Algorithms
- Pattern Searching
- Recursion
- Backtracking
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Randomized Algorithms
- Branch and Bound
- Algorithms Tutorial
- Complete DSA Tutorial
- Competitive Programming
- Company Wise SDE Sheets
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- Wipro Coding Sheet
- Infosys Coding Sheet
- TCS Coding Sheet
- Cognizant Coding Sheet
- HCL Coding Sheet
- DSA Cheat Sheets
- DSA Sheet for Beginners
- SDE Sheets
- FAANG Coding Sheet
- Love Babbar Sheet
- Mass Recruiter Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Top 100 DSA Interview Questions Topic-wise
- 100 Days of Code
- System Design
- System Design Tutorial
- Software Design Patterns
- System Design Roadmap
- Top 10 System Design Interview Questions
- Interview Corner
- Company Preparation
- Top Topics
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Multiple Choice Quizzes
- Aptitude for Placements
- Puzzles for Interviews
- Languages
- C
- C++
- Java
- Python
- R Tutorial
- C#
- SQL
- Scala
- Perl
- Go Language
- CS Subjects
- Engineering Mathematics
- Operating System
- DBMS
- Computer Networks
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- DevOps And Linux
- DevOps Tutorial
- GIT
- AWS
- Kubernetes
- Docker
- Microsoft Azure Tutorial
- Google Cloud Platform
- DevOps Roadmap
- DevOps Interview Questions
- Linux
- Linux Tutorial
- Linux Commands A-Z
- Linux Commands Cheatsheet
- File Permissions in Linux
- Linux System Administration
- Linux File System
- Linux Shell Scripting
- Linux Networking
- Linux Interview Questions
- School Learning
- Class 8 Study Material
- Class 9 Study Material
- Class 10 Study Material
- Class 11 Study Material
- Class 12 Study Material
- English Grammar
- GfG School
- Commerce
- GATE
- GATE CS/IT Test Series 2024
- GATE Computer Science Notes
- Last Minute Notes
- GATE CS Solved Papers
- GATE CS Original Papers and Official Keys
- GATE CS 2025 Syllabus
- GATE DA 2025 Syllabus
- Other CS Exams
- ISRO
- UGC NET
- GeeksforGeeks Videos
- HTML/CSS
- HTML
- HTML Tutorial
- HTML Tags
- HTML Attributes
- HTML Global Attributes
- HTML DOM
- HTML DOM Audio/Video
- HTML 5
- HTML SVG
- HTML Canvas
- MathML
- HTML Free Course
- HTML Examples
- CSS
- CSS Tutorial
- CSS Selectors
- CSS Properties
- CSS Functions
- CSS Examples
- CSS A to Z Guide
- CSS Free Course
- Bootstrap
- Bootstrap Tutorial
- Bootstrap 4 Tutorial
- Bootstrap 5 Tutorial
- CSS Frameworks
- HTML and CSS Projects
- HTML Formatter
- CSS Formatter
- Interview Questions
- HTML Interview Questions
- CSS Interview Questions
- Tailwind CSS Interview Questions
- JavaScript
- JavaScript
- JS Tutorial
- JS Array
- JS String
- JS Object
- JS Operators
- JS Set
- JS Map
- JS RegExp
- JS Math
- JS Date
- JS Number
- JS Boolean
- JS Programs
- JS Free Course
- JavaScript Design Patterns
- Learn JavaScript Programming
- JavaScript Programs
- JavaScript Examples
- JavaScript Array Programs
- JavaScript String Programs
- JavaScript Date Programs
- JavaScript Object Programs
- JavaScript Number Programs
- JavaScript Math Programs
- Javascript Set Programs
- Javascript Map Programs
- Top JavaScript Projects
- JS Frameworks
- Lodash
- Moment.js
- P5.js
- D3.js
- Underscore.js
- Collect.js
- TensorFlow.js
- Fabric.js
- jQuery
- jQuery Tutorial
- jQuery Selectors
- jQuery Events
- jQuery Effects
- jQuery HTML/CSS Methods
- jQuery AJAX
- jQuery Properties
- jQuery Plugins
- jQuery Examples
- jQuery UI
- jQuery Mobile
- ES6
- TypeScript Tutorial
- ReactJS Tutorial
- ReactJS Frameworks
- Next.js
- React Bootstrap
- Ant Design
- React Desktop
- React Rebass
- Blueprint
- React Suite
- Evergreen
- Node.js Tutorial
- Express.js Tutorial
- AngularJS
- Vue.js
- JSON
- Interview Corners
- JavaScript Interview Questions
- TypeScript Interview Questions
- jQuery Interview Questions
- AngularJS Interview Questions
- React Interview Questions
- Node Interview Questions
- MERN Stack Interview Questions
- CSS Tutorial
- CSS Exercises
- CSS Interview Questions
- CSS Selectors
- CSS Properties
- CSS Functions
- CSS Examples
- CSS Cheat Sheet
- CSS Templates
- CSS Frameworks
- Bootstrap
- Tailwind
- CSS Formatter
▲ Open In App - Solve Coding Problems
- Share Your Experience
- How to wrap table cell <td> content using CSS ?
- How to create equal width table cell using CSS ?
- How to wrap a text in a <pre> tag using CSS ?
- How to prevent text in a table cell from wrapping using CSS?
- How to create table cell using HTML5 ?
- How to put the caption below the table using CSS ?
- How create table without using <table> tag ?
- How to Create a Full-Width Table using CSS?
- How to set the table cell widths to minimum except last column using CSS ?
- How to group the body content in a table using HTML5 ?
- How to remove cellspacing from tables using CSS?
- How to set the table layout algorithm using CSS ?
- How to Get Text-Wrapping Effect using CSS ?
- How to group header content of a table using HTML5 ?
- How to add border-bottom to table row <tr> in CSS ?
- How to wrap the text around an image using HTML and CSS ?
- How to align right in a table cell using CSS ?
- How to create the tabular layout using CSS Property ?
- How to create a header cell in a table using HTML5 ?
- How to Change the Background Color of Table using CSS?
- Full Stack Development Course
How to wrap table cell <td> content using CSS ? Last Updated : 10 May, 2022 Improve Improve Like Article Like Save Share Report Tables in HTML are absurd elements. It is not an easy task to apply CSS properties to a table element. Being a highly structured element, CSS properties are sometimes lost in the hierarchy down the structure. It is also very likely that the contents of the table might change the structure or dimensions of the table. For example, long words residing in the table cells can cause the cell width to increases. If you fix that problem, it might happen that the long words cross the cell boundaries. We can avoid this by performing word wrap on the cell data.
There are two methods to wrap table cell <td> content using CSS which are given below:
- Using word-wrap property: This property is used to allow long words to break and wrap onto the next line.
- Using word-break property: This property is used to specify how to break the word when the word reached at end of the line. The line breaks in the text can occur in certain spaces, like when there is a space or a hyphen.
Example:
HTML
<!DOCTYPE html> <html> <head> <title> How to wrap table cell td content using CSS? </title> <style> h1, h3 { text-align: center; } table { border-spacing: 0px; table-layout: fixed; margin-left:auto; margin-right:auto; } th { color: green; border: 1px solid black; } td { border: 1px solid black; } </style> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Simple Example Without Word Wrap</h3> <table width="600"> <tr> <th>Course Name</th> <th>Specifications</th> <th>Duration</th> </tr> <tr> <td>Data Structures and Algorithms</td> <td> It includes pre-recorded premium <span style="color: red;"> Videolectures&programmingquestions </span> for practice. </td> <td>4 months</td> </tr> <tr> <td>GFG Placement Programme</td> <td> This course helps students to prepare for the Recruitment drive. </td> <td>3 months</td> </tr> </table> </body> </html>
Output:
![](https://media.geeksforgeeks.org/wp-content/uploads/20200413071104/wrap1-1024x454.png)
Note: In the above table, we have defined a table width of 600px and applied table-layout as fixed. Observe that a long word, which is marked red, is made by removing the spaces, for example purpose.
Method 1: Using word-wrap property: The word-wrap: break-word; property is used to break the long word at an appropriate break point.
Example:
HTML
<!DOCTYPE html> <html> <head> <title> How to wrap table cell td content using CSS? </title> <style> h1, h3 { text-align: center; } table { border-spacing: 0px; table-layout: fixed; margin-left: auto; margin-right: auto; } th { color: green; border: 1px solid black; } td { border: 1px solid black; word-wrap: break-word; } </style> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Wrap Table Cell td Content using word-wrap property</h3> <table width="600"> <tr> <th>Course Name</th> <th>Specifications</th> <th>Duration</th> </tr> <tr> <td>Data Structures and Algorithms</td> <td> It includes pre-recorded premium <span style="color: red;"> Videolectures&programmingquestions </span> for practice. </td> <td>4 months</td> </tr> <tr> <td>GFG Placement Programme</td> <td> This course helps students to prepare for the Recruitment drive. </td> <td>3 months</td> </tr> </table> </body> </html>
Output:
![](https://media.geeksforgeeks.org/wp-content/uploads/20200413070841/wrap21-1024x468.png)
Method 2: Using word-break property: The word-break: break-all; property is used to break the word at any character.
Example:
HTML
<!DOCTYPE html> <html> <head> <title> How to wrap table cell td content using CSS? </title> <style> h1, h3 { text-align: center; } table { border-spacing: 0px; table-layout: fixed; margin-left: auto; margin-right: auto; } th { color: green; border: 1px solid black; } td { border: 1px solid black; word-break: break-all; } </style> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Wrap Table Cell td Content using word-break property</h3> <table width="600"> <tr> <th>Course Name</th> <th>Specifications</th> <th>Duration</th> </tr> <tr> <td>Data Structures and Algorithms</td> <td> It includes pre-recorded premium <span style="color: red;"> Videolectures&programmingquestions </span> for practice. </td> <td>4 months</td> </tr> <tr> <td>GFG Placement Programme</td> <td> This course helps students to prepare for the Recruitment drive. </td> <td>3 months</td> </tr> </table> </body> </html>
Output:
![](https://media.geeksforgeeks.org/wp-content/uploads/20200413070844/wrap3-1024x434.png)
Note: Please note the difference between the outcome of both the properties. The word-wrap property wraps the word on a new line while word-break property continues to follow the flow and breaks at any appropriate character.
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
chitrankmishra Follow Improve Next Article How to create equal width table cell using CSS ? Please Login to comment...
Similar Reads
How to wrap an element with more content in flexbox container to have the same width as other elements in CSS ? In a flexbox container, we might have a scenario where you want to wrap an element with more content, such as text or an image, to have the same width as other elements. In this article, we will see how to wrap an element with more content in a flexbox container to have the same width as other elements using CSS. The flexbox or flexible box model i 3 min read What are Cell Padding & Cell Spacing in HTML Table ? In this article, we will discuss the cellpadding and cellspacing properties in HTML. These properties are used with the table tag for defining the spacing and padding of a table. Cellpadding: This property specifies the space between the border of a table cell and its contents (i.e) it defines the whitespace between the cell edge and the content of 2 min read Word-wrap in an HTML Table To enable word-wrap in an HTML table, apply the CSS property word-wrap: break-word; to the table cells (<td> or <th> elements). This ensures that long words or strings are broken into multiple lines within the table cell, preventing them from overflowing and maintaining readability. Table of Content Using CSS word-wrap PropertyUsing Inl 5 min read How to create equal width table cell using CSS ? HTML tables are created using the table tag with the combination of subsequent tags like tr tag to create a new row in the table. The th tag for table headers and td tag is used for defining a cell in the table. However, each cell of the table is by default designed to fit content of any size hence each changes its width according to the informatio 3 min read How to align right in a table cell using CSS ? In this article, we will be demonstrating how to align the data in the table cell to the right text-align property in CSS can be used to align the contents of the data in a given element. Approach: To align the contents of a table cell to right, we can use the text-align property in CSS. The cells which will be the table data can be styled using th 2 min read How to Define a Minimum Width for HTML Table Cell using CSS ? To set a minimum width for an HTML table cell using CSS, apply the min-width property directly to the <td> element, ensuring it does not shrink below the specified size. This ensures a minimum width for the cell content, maintaining layout integrity. Table of Content Using the min-width PropertyApplying a Class or IDUsing the min-width Proper 2 min read How to set the table cell widths to minimum except last column using CSS ? Tables are widely used for showing the data and sometimes we get into a scenario where we need some special kind of styling over the rows or the cells. We will explore one case where we must make the last column dynamic using CSS and the rest taking the required width. These are the following approaches: Table of Content Styling using classesStylin 3 min read How to prevent text in a table cell from wrapping using CSS? Ensuring readability and maintaining the layout of your tables in web design is crucial, especially when dealing with lengthy text in table cells. The CSS white-space property helps you control text wrapping within table cells, ensuring that content stays on one line. This article will walk you through the various values of the white-space property 2 min read How to wrap a text in a <pre> tag using CSS ? In this article, we will learn how to wrap a text in a <pre> tag. The <pre> tag is used to display the block of preformatted text which preserves the text spaces, line breaks, tabs, and other formatting characters which are ignored by web browsers. By default, the <pre> tag does not support the <pre> tag. In the case of rend 2 min read How to wrap the text around an image using HTML and CSS ? Wrapping the text around an image is quite attractive for any kind of website. By using HTML and CSS wrapping an image with the text is possible and there are many ways to do so because the shape of any image is not constant. In HTML : You can also use CSS shape-outside Property depending on the shape of your image.Align images to the right, left, 4 min read View More Articles Article Tags : - CSS-Questions
- CSS
- Web Technologies
Like
254k+ interested Geeks Full Stack Development with React & Node JS - Live Explore
6k+ interested Geeks Complete Bootstrap Course For Beginners Explore
117k+ interested Geeks GATE Computer Science & Information Technology 2025 Explore Explore More We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It !
Improvement Please go through our recently updated Improvement Guidelines before submitting any improvements. This article is being improved by another user right now. You can suggest the changes for now and it will be under the article's discussion tab. You will be notified via email once the article is available for improvement. Thank you for your valuable feedback! Suggest changes Please go through our recently updated Improvement Guidelines before submitting any improvements. Suggest Changes Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
Create Improvement Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
Suggest Changes Suggestion[CharLimit:2000] Create Improvement What kind of Experience do you want to share?
Interview Experiences Admission Experiences Career Journeys Work Experiences Campus Experiences Competitive Exam Experiences Can't choose a topic to write? click here for suggested topics Write and publish your own Article
Từ khóa » Html Table Fixed Column Width Not Word Wrap
-
Html - Table Cell Widths - Fixing Width, Wrapping/truncating Long Words
-
How To Wrap The Content Of A Table Cell - W3docs
-
Wrap Or Break Long Word (text) In HTML Table Cell - Dev Bay
-
Table-layout - CSS: Cascading Style Sheets - MDN Web Docs
-
Overflow-wrap - CSS: Cascading Style Sheets - MDN Web Docs
-
Table Column Header Text Wrap Code Example
-
CSS Table-layout Property - W3Schools
-
Wrap Long Text (without Space) In Html Table Cell - MSDN - Microsoft
-
DataTable Width & Column Width | Dash For Python Documentation
-
How To Break Long Words In An HTML (or CSS) Table - Design-fluide
-
Sql Server Email Html Table Column Wrap - Microsoft Q&A
-
Table Layout And Word Wrap - WpDataTables Tables And Charts Plugin
-
Fixed Table Layouts | CSS-Tricks
-
[Solved -11 Answers] HTML – Word-wrap In An HTML Table - Wikitechy
Liên Hệ
TRUYỀN HÌNH CÁP SÔNG THU ĐÀ NẴNG
Địa Chỉ: 58 Hàm Nghi - Đà Nẵng
Phone: 0904961917
Facebook: https://fb.com/truyenhinhcapsongthu/
Twitter: @ Capsongthu
Copyright © 2022 | Thiết Kế Truyền Hình Cáp Sông Thu
Trang chủ » Html Table Fixed Column Width Not Word Wrap » How To Wrap Table Cell
Có thể bạn quan tâm
- Courses
- DSA to Development
- For Working Professionals
- Data Structure & Algorithm Classes (Live)
- System Design (Live)
- JAVA Backend Development(Live)
- DevOps(Live)
- Data Structures & Algorithms in Python
- For Students
- Interview Preparation Course
- GATE CS & IT 2024
- Data Science (Live)
- Data Structure & Algorithm-Self Paced(C++/JAVA)
- Master Competitive Programming(Live)
- Full Stack Development with React & Node JS(Live)
- For School Students
- CBSE Class 12 Computer Science
- School Guide
- Python Programming Foundation
- All Courses
- Tutorials
- Web Development
- Web Development Roadmap
- Front-End Development
- Back-End Development
- Full Stack Development
- MERN Stack
- MEAN Stack
- PHP Tutorial
- WordPress Tutorial
- Web Development Projects
- Front End Developer Interview Questions
- Learn Web Designing
- Web Development using Python
- Django
- Django Tutorial
- Top Django Projects
- Django Interview Questions
- Flask
- Flask Tutorial
- Python Flask Projects
- Flask Interview Questions
- Postman
- Github
- Web Scrapping in Python
- Django
- ML & Data Science
- Machine Learning
- Machine Learning Tutorial
- Maths for ML
- ML Projects
- 100 Days of Machine Learning
- Data Science Tutorial
- Data Science Packages
- Pandas Tutorial
- NumPy Tutorial
- Data Visualization
- Data Visualization with Python
- Data Visualization with R
- Tableau
- Power BI
- Data Analysis
- Data Analysis with Python
- Data Analysis with R
- 100 Days of Data Analytics
- Deep Learning
- NLP Tutorial
- OpenCV Tutorial
- Interview Questions
- Machine Learning Interview Question
- Deep Learning Interview Question
- R Interview Questions
- Machine Learning
- Data Structures & Algorithms
- DSA for Beginners
- Data Structures
- Arrays
- Matrix
- Strings
- Linked List
- Stack
- Queue
- Tree
- Generic Tree
- Binary Tree
- Binary Search Tree
- AVL Tree
- B Tree
- B+ Tree
- Red Black Tree
- Tree Data Structure Tutorial
- Heap
- Hashing
- Graph
- Set Data Structure
- Map Data Structure
- Advanced Data Structure
- Data Structures Tutorial
- Algorithms
- Analysis of Algorithms
- Searching Algorithms
- Linear Search
- Binary Search
- Searching Algorithms Tutorial
- Sorting Algorithms
- Selection Sort
- Bubble Sort
- Insertion Sort
- Merge Sort
- Quick Sort
- Heap Sort
- Counting Sort
- Radix Sort
- Bucket Sort
- Sorting Algorithms Tutorial
- Greedy Algorithms
- Dynamic Programming
- Graph Algorithms
- Pattern Searching
- Recursion
- Backtracking
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Randomized Algorithms
- Branch and Bound
- Algorithms Tutorial
- Complete DSA Tutorial
- Competitive Programming
- Company Wise SDE Sheets
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- Wipro Coding Sheet
- Infosys Coding Sheet
- TCS Coding Sheet
- Cognizant Coding Sheet
- HCL Coding Sheet
- DSA Cheat Sheets
- DSA Sheet for Beginners
- SDE Sheets
- FAANG Coding Sheet
- Love Babbar Sheet
- Mass Recruiter Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Top 100 DSA Interview Questions Topic-wise
- 100 Days of Code
- System Design
- System Design Tutorial
- Software Design Patterns
- System Design Roadmap
- Top 10 System Design Interview Questions
- Interview Corner
- Company Preparation
- Top Topics
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Multiple Choice Quizzes
- Aptitude for Placements
- Puzzles for Interviews
- Languages
- C
- C++
- Java
- Python
- R Tutorial
- C#
- SQL
- Scala
- Perl
- Go Language
- CS Subjects
- Engineering Mathematics
- Operating System
- DBMS
- Computer Networks
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- DevOps And Linux
- DevOps Tutorial
- GIT
- AWS
- Kubernetes
- Docker
- Microsoft Azure Tutorial
- Google Cloud Platform
- DevOps Roadmap
- DevOps Interview Questions
- Linux
- Linux Tutorial
- Linux Commands A-Z
- Linux Commands Cheatsheet
- File Permissions in Linux
- Linux System Administration
- Linux File System
- Linux Shell Scripting
- Linux Networking
- Linux Interview Questions
- School Learning
- Class 8 Study Material
- Class 9 Study Material
- Class 10 Study Material
- Class 11 Study Material
- Class 12 Study Material
- English Grammar
- GfG School
- Commerce
- GATE
- GATE CS/IT Test Series 2024
- GATE Computer Science Notes
- Last Minute Notes
- GATE CS Solved Papers
- GATE CS Original Papers and Official Keys
- GATE CS 2025 Syllabus
- GATE DA 2025 Syllabus
- Other CS Exams
- ISRO
- UGC NET
- GeeksforGeeks Videos
- Web Development
- HTML/CSS
- HTML
- HTML Tutorial
- HTML Tags
- HTML Attributes
- HTML Global Attributes
- HTML DOM
- HTML DOM Audio/Video
- HTML 5
- HTML SVG
- HTML Canvas
- MathML
- HTML Free Course
- HTML Examples
- CSS
- CSS Tutorial
- CSS Selectors
- CSS Properties
- CSS Functions
- CSS Examples
- CSS A to Z Guide
- CSS Free Course
- Bootstrap
- Bootstrap Tutorial
- Bootstrap 4 Tutorial
- Bootstrap 5 Tutorial
- CSS Frameworks
- HTML and CSS Projects
- HTML Formatter
- CSS Formatter
- Interview Questions
- HTML Interview Questions
- CSS Interview Questions
- Tailwind CSS Interview Questions
- HTML
- JavaScript
- JavaScript
- JS Tutorial
- JS Array
- JS String
- JS Object
- JS Operators
- JS Set
- JS Map
- JS RegExp
- JS Math
- JS Date
- JS Number
- JS Boolean
- JS Programs
- JS Free Course
- JavaScript Design Patterns
- Learn JavaScript Programming
- JavaScript Programs
- JavaScript Examples
- JavaScript Array Programs
- JavaScript String Programs
- JavaScript Date Programs
- JavaScript Object Programs
- JavaScript Number Programs
- JavaScript Math Programs
- Javascript Set Programs
- Javascript Map Programs
- Top JavaScript Projects
- JS Frameworks
- Lodash
- Moment.js
- P5.js
- D3.js
- Underscore.js
- Collect.js
- TensorFlow.js
- Fabric.js
- jQuery
- jQuery Tutorial
- jQuery Selectors
- jQuery Events
- jQuery Effects
- jQuery HTML/CSS Methods
- jQuery AJAX
- jQuery Properties
- jQuery Plugins
- jQuery Examples
- jQuery UI
- jQuery Mobile
- ES6
- TypeScript Tutorial
- ReactJS Tutorial
- ReactJS Frameworks
- Next.js
- React Bootstrap
- Ant Design
- React Desktop
- React Rebass
- Blueprint
- React Suite
- Evergreen
- Node.js Tutorial
- Express.js Tutorial
- AngularJS
- Vue.js
- JSON
- Interview Corners
- JavaScript Interview Questions
- TypeScript Interview Questions
- jQuery Interview Questions
- AngularJS Interview Questions
- React Interview Questions
- Node Interview Questions
- MERN Stack Interview Questions
- JavaScript
- CSS Tutorial
- CSS Exercises
- CSS Interview Questions
- CSS Selectors
- CSS Properties
- CSS Functions
- CSS Examples
- CSS Cheat Sheet
- CSS Templates
- CSS Frameworks
- Bootstrap
- Tailwind
- CSS Formatter
- Solve Coding Problems
- Share Your Experience
- How to wrap table cell <td> content using CSS ?
- How to create equal width table cell using CSS ?
- How to wrap a text in a <pre> tag using CSS ?
- How to prevent text in a table cell from wrapping using CSS?
- How to create table cell using HTML5 ?
- How to put the caption below the table using CSS ?
- How create table without using <table> tag ?
- How to Create a Full-Width Table using CSS?
- How to set the table cell widths to minimum except last column using CSS ?
- How to group the body content in a table using HTML5 ?
- How to remove cellspacing from tables using CSS?
- How to set the table layout algorithm using CSS ?
- How to Get Text-Wrapping Effect using CSS ?
- How to group header content of a table using HTML5 ?
- How to add border-bottom to table row <tr> in CSS ?
- How to wrap the text around an image using HTML and CSS ?
- How to align right in a table cell using CSS ?
- How to create the tabular layout using CSS Property ?
- How to create a header cell in a table using HTML5 ?
- How to Change the Background Color of Table using CSS?
- Full Stack Development Course
Tables in HTML are absurd elements. It is not an easy task to apply CSS properties to a table element. Being a highly structured element, CSS properties are sometimes lost in the hierarchy down the structure. It is also very likely that the contents of the table might change the structure or dimensions of the table. For example, long words residing in the table cells can cause the cell width to increases. If you fix that problem, it might happen that the long words cross the cell boundaries. We can avoid this by performing word wrap on the cell data.
There are two methods to wrap table cell <td> content using CSS which are given below:
- Using word-wrap property: This property is used to allow long words to break and wrap onto the next line.
- Using word-break property: This property is used to specify how to break the word when the word reached at end of the line. The line breaks in the text can occur in certain spaces, like when there is a space or a hyphen.
Example:
HTML
<!DOCTYPE html> <html> <head> <title> How to wrap table cell td content using CSS? </title> <style> h1, h3 { text-align: center; } table { border-spacing: 0px; table-layout: fixed; margin-left:auto; margin-right:auto; } th { color: green; border: 1px solid black; } td { border: 1px solid black; } </style> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Simple Example Without Word Wrap</h3> <table width="600"> <tr> <th>Course Name</th> <th>Specifications</th> <th>Duration</th> </tr> <tr> <td>Data Structures and Algorithms</td> <td> It includes pre-recorded premium <span style="color: red;"> Videolectures&programmingquestions </span> for practice. </td> <td>4 months</td> </tr> <tr> <td>GFG Placement Programme</td> <td> This course helps students to prepare for the Recruitment drive. </td> <td>3 months</td> </tr> </table> </body> </html> |
Output:
Note: In the above table, we have defined a table width of 600px and applied table-layout as fixed. Observe that a long word, which is marked red, is made by removing the spaces, for example purpose.
Method 1: Using word-wrap property: The word-wrap: break-word; property is used to break the long word at an appropriate break point.
Example:
HTML
<!DOCTYPE html> <html> <head> <title> How to wrap table cell td content using CSS? </title> <style> h1, h3 { text-align: center; } table { border-spacing: 0px; table-layout: fixed; margin-left: auto; margin-right: auto; } th { color: green; border: 1px solid black; } td { border: 1px solid black; word-wrap: break-word; } </style> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Wrap Table Cell td Content using word-wrap property</h3> <table width="600"> <tr> <th>Course Name</th> <th>Specifications</th> <th>Duration</th> </tr> <tr> <td>Data Structures and Algorithms</td> <td> It includes pre-recorded premium <span style="color: red;"> Videolectures&programmingquestions </span> for practice. </td> <td>4 months</td> </tr> <tr> <td>GFG Placement Programme</td> <td> This course helps students to prepare for the Recruitment drive. </td> <td>3 months</td> </tr> </table> </body> </html> |
Output:
Method 2: Using word-break property: The word-break: break-all; property is used to break the word at any character.
Example:
HTML
<!DOCTYPE html> <html> <head> <title> How to wrap table cell td content using CSS? </title> <style> h1, h3 { text-align: center; } table { border-spacing: 0px; table-layout: fixed; margin-left: auto; margin-right: auto; } th { color: green; border: 1px solid black; } td { border: 1px solid black; word-break: break-all; } </style> </head> <body> <h1 style="color:green;">GeeksforGeeks</h1> <h3>Wrap Table Cell td Content using word-break property</h3> <table width="600"> <tr> <th>Course Name</th> <th>Specifications</th> <th>Duration</th> </tr> <tr> <td>Data Structures and Algorithms</td> <td> It includes pre-recorded premium <span style="color: red;"> Videolectures&programmingquestions </span> for practice. </td> <td>4 months</td> </tr> <tr> <td>GFG Placement Programme</td> <td> This course helps students to prepare for the Recruitment drive. </td> <td>3 months</td> </tr> </table> </body> </html> |
Output:
Note: Please note the difference between the outcome of both the properties. The word-wrap property wraps the word on a new line while word-break property continues to follow the flow and breaks at any appropriate character.
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
Please Login to comment...
Similar Reads
How to wrap an element with more content in flexbox container to have the same width as other elements in CSS ? In a flexbox container, we might have a scenario where you want to wrap an element with more content, such as text or an image, to have the same width as other elements. In this article, we will see how to wrap an element with more content in a flexbox container to have the same width as other elements using CSS. The flexbox or flexible box model i 3 min read What are Cell Padding & Cell Spacing in HTML Table ? In this article, we will discuss the cellpadding and cellspacing properties in HTML. These properties are used with the table tag for defining the spacing and padding of a table. Cellpadding: This property specifies the space between the border of a table cell and its contents (i.e) it defines the whitespace between the cell edge and the content of 2 min read Word-wrap in an HTML Table To enable word-wrap in an HTML table, apply the CSS property word-wrap: break-word; to the table cells (<td> or <th> elements). This ensures that long words or strings are broken into multiple lines within the table cell, preventing them from overflowing and maintaining readability. Table of Content Using CSS word-wrap PropertyUsing Inl 5 min read How to create equal width table cell using CSS ? HTML tables are created using the table tag with the combination of subsequent tags like tr tag to create a new row in the table. The th tag for table headers and td tag is used for defining a cell in the table. However, each cell of the table is by default designed to fit content of any size hence each changes its width according to the informatio 3 min read How to align right in a table cell using CSS ? In this article, we will be demonstrating how to align the data in the table cell to the right text-align property in CSS can be used to align the contents of the data in a given element. Approach: To align the contents of a table cell to right, we can use the text-align property in CSS. The cells which will be the table data can be styled using th 2 min read How to Define a Minimum Width for HTML Table Cell using CSS ? To set a minimum width for an HTML table cell using CSS, apply the min-width property directly to the <td> element, ensuring it does not shrink below the specified size. This ensures a minimum width for the cell content, maintaining layout integrity. Table of Content Using the min-width PropertyApplying a Class or IDUsing the min-width Proper 2 min read How to set the table cell widths to minimum except last column using CSS ? Tables are widely used for showing the data and sometimes we get into a scenario where we need some special kind of styling over the rows or the cells. We will explore one case where we must make the last column dynamic using CSS and the rest taking the required width. These are the following approaches: Table of Content Styling using classesStylin 3 min read How to prevent text in a table cell from wrapping using CSS? Ensuring readability and maintaining the layout of your tables in web design is crucial, especially when dealing with lengthy text in table cells. The CSS white-space property helps you control text wrapping within table cells, ensuring that content stays on one line. This article will walk you through the various values of the white-space property 2 min read How to wrap a text in a <pre> tag using CSS ? In this article, we will learn how to wrap a text in a <pre> tag. The <pre> tag is used to display the block of preformatted text which preserves the text spaces, line breaks, tabs, and other formatting characters which are ignored by web browsers. By default, the <pre> tag does not support the <pre> tag. In the case of rend 2 min read How to wrap the text around an image using HTML and CSS ? Wrapping the text around an image is quite attractive for any kind of website. By using HTML and CSS wrapping an image with the text is possible and there are many ways to do so because the shape of any image is not constant. In HTML : You can also use CSS shape-outside Property depending on the shape of your image.Align images to the right, left, 4 min read View More Articles Article Tags :- CSS-Questions
- CSS
- Web Technologies
![three90RightbarBannerImg](https://media.geeksforgeeks.org/auth-dashboard-uploads/300x250_SS_Right_Bar.2-%281%29.png)
![course-img](https://media.geeksforgeeks.org/img-practice/prod/courses/241/Web/Content/FSRNL_1705410152.webp)
![course-img](https://media.geeksforgeeks.org/img-practice/prod/courses/439/Web/Content/bootstrap-graphic_1705401384.webp)
![course-img](https://media.geeksforgeeks.org/img-practice/prod/courses/402/Web/Content/gate-2025_1705410647.webp)
![geeksforgeeks-suggest-icon](https://media.geeksforgeeks.org/auth-dashboard-uploads/suggestChangeIcon.png)
![geeksforgeeks-improvement-icon](https://media.geeksforgeeks.org/auth-dashboard-uploads/createImprovementIcon.png)
What kind of Experience do you want to share?
Interview Experiences Admission Experiences Career Journeys Work Experiences Campus Experiences Competitive Exam Experiences Can't choose a topic to write? click here for suggested topics Write and publish your own ArticleTừ khóa » Html Table Fixed Column Width Not Word Wrap
-
Html - Table Cell Widths - Fixing Width, Wrapping/truncating Long Words
-
How To Wrap The Content Of A Table Cell - W3docs
-
Wrap Or Break Long Word (text) In HTML Table Cell - Dev Bay
-
Table-layout - CSS: Cascading Style Sheets - MDN Web Docs
-
Overflow-wrap - CSS: Cascading Style Sheets - MDN Web Docs
-
Table Column Header Text Wrap Code Example
-
CSS Table-layout Property - W3Schools
-
Wrap Long Text (without Space) In Html Table Cell - MSDN - Microsoft
-
DataTable Width & Column Width | Dash For Python Documentation
-
How To Break Long Words In An HTML (or CSS) Table - Design-fluide
-
Sql Server Email Html Table Column Wrap - Microsoft Q&A
-
Table Layout And Word Wrap - WpDataTables Tables And Charts Plugin
-
Fixed Table Layouts | CSS-Tricks
-
[Solved -11 Answers] HTML – Word-wrap In An HTML Table - Wikitechy
Liên Hệ
TRUYỀN HÌNH CÁP SÔNG THU ĐÀ NẴNG
Địa Chỉ: 58 Hàm Nghi - Đà Nẵng
Phone: 0904961917
Facebook: https://fb.com/truyenhinhcapsongthu/
Twitter: @ Capsongthu
Copyright © 2022 | Thiết Kế Truyền Hình Cáp Sông Thu