• Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / tutorials / HTML & CSS Tutorials / ways to create responsive table fit to screen mobile

ways to create responsive table fit to screen mobile

 

goal

table fit in mobile without breaking words.

table fit according to viewport.

Table of Contents

Toggle
  • Create a Full-width Table
  • relative units
  • Use media queries
  • overflow properties
    • table text fit in table
  • CSS Syntax
    • 1. Using word-wrap property
    • 2. Using word-break Property

Create a Full-width Table

table {
width: 100%;
}

 

relative units

For example, you can use width: 100% to make your table take up the full width of its container, or width: 50% to make it half as wide.

Use media queries

use @media (max-width: 600px) to apply a different style to your table when the screen width is less than 600 pixels,

@media only screen and (max-width: 480px) {
    /* horizontal scrollbar for tables if mobile screen */
    .tablemobile {
        overflow-x: auto;
        display: block;
    }
}

 

Use flexbox or grid

overflow properties

you can use overflow: scroll to add a horizontal scrollbar to your table, or overflow: hidden to clip the excess content. Alternatively, you can use overflow-wrap: break-word or word-break: break-all to break long words or lines within the table cells.

overflow-x:auto

If you’re using really wide margins, padding, borders, etc., try reducing their size (but I’m sure you thought of that).

word-wrap: break-word;  Allows unbreakable words to be broken  not looks good.

 

 

html {
font-size: 100%; /* 16px browser default */
}

table,td,th {
border: 1px solid var(--ast-border-color)
}

table {
border-collapse: separate;
border-spacing: 0;
border-width: 1px 0 0 1px;
margin: 0 0 1.5em;
width: 100%
}

th {
font-weight: 700
}

td,th {
padding: 8px;
border-width: 0 1px 1px 0
}

 

table {
margin-left: -16px;
}

table {
margin-right: 16px;
}

table {
width: 109%;
}

ul.table {
list-style-position: inside;
}

li {
margin-left: -20px;
margin-bottom: 7px;
}

table {
font-size: 0.9em;

0.9 em = 14.4 px
}

table td, table th {
padding: 9px;
line-height: 1.4;
vertical-align: top;
border: 1px solid #ccc;
margin: 5px:
}

 

table text fit in table

CSS Syntax

word-break: normal|break-all|keep-all|break-word|initial|inherit;

1. Using word-wrap property

The word-wrap: break-word; property is used to break the long word at an appropriate break point.

Syntax

word-wrap: break-word;

i guess this is the best.

2. Using word-break Property

The word-break: break-all; property is used to break the word at any character.

Syntax

word-break: break-all;

break-all
.site-content {
/* word-wrap: break-word;

table responsive text nowrap

word-break: normal; default
https://www.w3schools.com/cssref/playdemo.php?filename=playcss_word-break

media queries specific css


Breakpoint Setting For Device
max-width 320px Smartwatches
max-width 420px Smaller devices
max-width 600px Phones
min-width 600px Tablets and Large Phones
min-width 768px Tablets
min-width 992px Laptops and Desktops
min-width 1200px Monitors, Desktops

Here is an example order for the max-width approach:

Desktop styles (not in a media query)
Tablet styles (max-width: 768px)
Mobile styles (max-width: 414px)

@media only screen and (min-width: 600px) {...}

What this query really means is, “If [device width] is greater than or equal to 600px, then do {...}“

 

@media only screen and (max-width: 600px) {...}

What this query really means is, “If [device width] is less than or equal to 600px, then do {...}.”

tutorials

  • Core Java Tutorial Free online
  • HTML & CSS Tutorials
    • ways to create responsive table fit to screen mobile
  • Php tutorials
  • ubuntu tutorials installation download issues etc
  • redis install ubuntu 20.04 with wordpress php redis mysql configuration
  • [INTRO] Ethical hacking / cyber Security / Penetration testing Tutorial -{updates frequently}
  • Android Studio tutorials syllabus Topics Course details #AndroidApplicationDevelopment
  • AUdio Editing Background Noise removal (Audacity, Adobe Premiere Addition, Camtasia Filmora Windows Obs)
  • what is vpn vs proxy vs tor, http vs https, http2, tcp vs udp, kali linux sql source code injection
  • how to create a website free of cost on google
  • CCNA Syllabus pdf (CCNA / CCNP vs devops vs mcsa /MCSE)
  • Redis performance metrics & tuning for nginx apache ubuntu & debian
  • xampp tutorials 2021 installation errors fix wordpress phpmyadmin mysql apache
  • new relic installation linux (infrastructure agent , php, mysql , nginx)
  • new relic mysql install integration - 2 ways fix problems
  • new relic php agent install in 3 steps
  • aws load balancer tutorial
  • git branches merge fetch pull conflicts

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy