{"id":3019,"date":"2016-12-04T10:49:32","date_gmt":"2016-12-04T16:49:32","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=1994"},"modified":"2016-12-04T10:49:32","modified_gmt":"2016-12-04T16:49:32","slug":"css-snippets-how-to-style-a-table","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/css-snippets-how-to-style-a-table\/","title":{"rendered":"CSS Snippets: How to Style a Table"},"content":{"rendered":"<p>Tables are one of the trickiest and most complex of the &#8220;basic&#8221; HTML elements. They require a lot of specific tags to create, every browser has its own very different inherent styles for them (this can make styling a nightmare), and they&#8217;re not particularly mobile-friendly, at least not unless you really manipulate them with CSS or jQuery. And still, tables aren&#8217;t obsolete. While they aren&#8217;t used to create layouts like they were before, they&#8217;re still very necessary and useful for things like displaying data. If you&#8217;re looking for some cool, modern ways to update your tables (and every make them responsive!), check out some of the snippets below:<\/p>\n<p>1. <a href=\"http:\/\/codepen.io\/mestremind\/pen\/IyDpa\">Stylish Data Table<\/a><\/p>\n<p><a href=\"http:\/\/codepen.io\/mestremind\/pen\/IyDpa\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-2020 aligncenter\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2016\/12\/Screen-Shot-2016-12-04-at-11.44.38-AM.png\" alt=\"Screen Shot 2016-12-04 at 11.44.38 AM\" width=\"648\" height=\"301\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>This snippet demonstrates how to create a simple but very sleek and modern table. It also includes some subtle highlighting hover effects and a light box shadow to create the illusion of a floating table element.<\/p>\n<p>2. <a href=\"http:\/\/codepen.io\/alassetter\/pen\/cyrfB\" target=\"_blank\" rel=\"noopener noreferrer\">Basic Data Table<\/a><\/p>\n<p><a href=\"http:\/\/codepen.io\/alassetter\/pen\/cyrfB\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-2021 aligncenter\" src=\"http:\/\/cssnewbie.com\/wp-content\/uploads\/2016\/12\/Screen-Shot-2016-12-04-at-11.47.11-AM-1024x553.png\" alt=\"Screen Shot 2016-12-04 at 11.47.11 AM\" width=\"650\" height=\"351\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>This tutorial demonstrates how to make a very basic data table. It&#8217;s much less flashy than the one in the first example, however it still manages to be\u00a0a clean, modern departure from any default table styles.<\/p>\n<p>3. <a href=\"http:\/\/codepen.io\/aurer\/pen\/HKtbe\" target=\"_blank\" rel=\"noopener noreferrer\">Responsive Table<\/a><\/p>\n<p><a href=\"http:\/\/codepen.io\/aurer\/pen\/HKtbe\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-2022 aligncenter\" src=\"http:\/\/cssnewbie.com\/wp-content\/uploads\/2016\/12\/Screen-Shot-2016-12-04-at-11.50.37-AM-1024x236.png\" alt=\"Screen Shot 2016-12-04 at 11.50.37 AM\" width=\"660\" height=\"152\" \/><\/a><\/p>\n<p>Have you ever struggled with creating a responsive table? If so, this snippet has your answers. The data table created is fully responsive so that it works when it&#8217;s viewed at full size, but if the screen shrinks the cells\u00a0rearrange so that the data not only fits within a smaller viewport, but can also still be read logically at that size.<\/p>\n<p>4. <a href=\"http:\/\/codepen.io\/alexerlandsson\/pen\/mPWgpO\" target=\"_blank\" rel=\"noopener noreferrer\">Pure CSS Table with Highlight<\/a><\/p>\n<p><a href=\"http:\/\/codepen.io\/alexerlandsson\/pen\/mPWgpO\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-2023 aligncenter\" src=\"http:\/\/cssnewbie.com\/wp-content\/uploads\/2016\/12\/Screen-Shot-2016-12-04-at-11.53.13-AM-1024x381.png\" alt=\"Screen Shot 2016-12-04 at 11.53.13 AM\" width=\"650\" height=\"242\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>This stylish table comes with very cool highlight effects that appear when a cell is hovered upon. It&#8217;s pure CSS so it&#8217;s very lightweight and easy to customize and add to any of your projects.<\/p>\n<p>5. <a href=\"http:\/\/codepen.io\/nikhil8krishnan\/pen\/WvYPvv\" target=\"_blank\" rel=\"noopener noreferrer\">Table with Fixed Header<\/a><\/p>\n<p><a href=\"http:\/\/codepen.io\/nikhil8krishnan\/pen\/WvYPvv\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-2024 aligncenter\" src=\"http:\/\/cssnewbie.com\/wp-content\/uploads\/2016\/12\/Screen-Shot-2016-12-04-at-11.55.21-AM-1024x197.png\" alt=\"Screen Shot 2016-12-04 at 11.55.21 AM\" width=\"650\" height=\"125\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The great thing about this table snippet is that it creates a table where the header is fixed, so no matter how far you scroll down through the data, the header always remains at the top, in case you need to reference which data belongs to which column or category.<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Tables are one of the trickiest and most complex of the &#8220;basic&#8221; HTML elements. They require a lot of specific tags to create, every browser has its own very different inherent styles for them (this can make styling a nightmare), [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/css-snippets-how-to-style-a-table\/\" title=\"Click to read 'CSS Snippets: How to Style a Table'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":2788,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3019"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=3019"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3019\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media\/2788"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=3019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=3019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=3019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}