{"id":23888,"date":"2019-05-14T23:32:02","date_gmt":"2019-05-14T15:32:02","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=23888"},"modified":"2020-06-23T17:28:20","modified_gmt":"2020-06-23T09:28:20","slug":"useful-css-tricks-you-might-have-overlooked","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/","title":{"rendered":"15 Useful CSS Tricks You Might Have Overlooked"},"content":{"rendered":"<p>If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code something and realised after a bit of googling, that \u201cthere is CSS for that\u201d. If you hadn\u2019t, well you are about to.<\/p>\n<p>This post is a collection of such <a href=\"https:\/\/www.hongkiat.com\/blog\/simple-css-snippets\/\">CSS codes<\/a>, that can give you features like turn an element sticky, give you dashed line underlining capabilities, flow the text of your page in a special shape, or achieve parallax effect. Some of them are widely supported while others are on their way for full support by all browsers.<\/p>\n<h2>Numbering headings and subheadings<\/h2>\n<p>Say you got a set of headings and subheadings in your document and you are numbering them manually or via a script. Instead, you can use CSS counters to do this. There is already an in-depth post on it <a href=\"https:\/\/www.hongkiat.com\/blog\/css-automatic-numbering\/\">here<\/a>. And since it is from a CSS2 spec, you can bet that it is supported by all browsers, except perhaps IE 6.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"css,result\" data-user=\"rpsthecoder\" data-slug-hash=\"GJRLWj\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"GJRLWj\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/GJRLWj\/\" rel=\"nofollow\"> GJRLWj<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Spice up plain underlines<\/h2>\n<p>Sometimes we want to underline with a nice dotted or dashed line instead of a solid one. Since there is no option for that, we settle for <code>border-bottom<\/code>. But <code>border-bottom<\/code> is not a good solution if the <a href=\"https:\/\/www.hongkiat.com\/blog\/change-default-text-wrapping-html-css\/\">text you are underlining wraps<\/a>.<\/p>\n<p>CSS3 specified not one but three new properties for text decoration <strong><code>text-decoration-color<\/code><\/strong>, <strong><code>text-decoration-line<\/code><\/strong>, and <strong><code>text-decoration-style<\/code><\/strong> which can be shorthanded into the good old <strong>text-decoration<\/strong>.<\/p>\n<p>You can use those to style underline, overline, even make text blink, and more. As of April 2015 only Firefox supports this property, but you can enable \u201cexperimental web platform features\u201d to use it on Chrome.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"css,result\" data-user=\"rpsthecoder\" data-slug-hash=\"YXzMQw\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"YXzMQw\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/YXzMQw\/\" rel=\"nofollow\"> YXzMQw<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Quoting a quote<\/h2>\n<p>First of all, there is no need to bother with typing the correct curly quotes for short quotations because there is HTML for that: the <code>&lt;q&gt;<\/code> tag that indicates inline quotations.<\/p>\n<p>The <code>&lt;q&gt;<\/code> tag also takes care of quoting the inner quotes with single quotes. So, where is the \u201cthere is \u2018CSS\u2019 for that\u201d moment in this?<\/p>\n<p>Lets say you don\u2019t want the default double quotes or you have more than one level of nested quotes, you can define your quote preferences for the quote element with CSS by using the CSS2 <strong>quotes<\/strong> property.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"VLwNzv\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"VLwNzv\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/VLwNzv\/\" rel=\"nofollow\"> VLwNzv<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Managing unruly tables<\/h2>\n<p>You may have come across a big table with varying content size per cell which refuses to remain within a width you have specified, no matter what you try. Tame that table with the <strong><code>table-layout<\/code><\/strong> property (for equal column height, follow this <a href=\"https:\/\/www.hongkiat.com\/blog\/css-equal-height\/\">link<\/a>).<\/p>\n<p>To be specific, the fix is in the <strong> table-layout: fixed;<\/strong> value. When you assign a fixed layout for the table, the table and the cell width are determined by the width of the table or of the first row of cells (which can be defined by the user) and not by the content. This is supported by all browsers.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"NqWmvw\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"NqWmvw\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/NqWmvw\/\" rel=\"nofollow\"> NqWmvw<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Make it sticky<\/h2>\n<p><a href=\"https:\/\/www.hongkiat.com\/blog\/sticky-elements-jquery-plugins\/\">Sticky elements<\/a> are elements on a page that will not be scrolled out of view. In other words it sticks to a visible area (viewport or scrolling box). You can create this with CSS using <strong>position: sticky;<\/strong>.<\/p>\n<p>They act like relatively postioned elements before any scrolling and later like fixed elements once a scrolling threshold is reached. For now, <strong>only Firefox<\/strong> supports it.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"css,result\" data-user=\"rpsthecoder\" data-slug-hash=\"zGYXEX\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"position:sticky (CSS)\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/zGYXEX\/\" rel=\"nofollow\"> position:sticky (CSS)<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Get your text in shape<\/h2>\n<p>Do you want the text on your page to nicely curve over some image you displayed beside it? You can try <strong>CSS Shapes<\/strong>. To implement CSS shapes, we can make use of three properties <code>shape-outside<\/code>, <code>shape-margin<\/code> and <code>shape-image-threshold<\/code>. As of April, 2015 CSS Shapes is supported by<strong> webkit browsers<\/strong>.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"RPNNQG\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"CSS Shape.\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/RPNNQG\/\" rel=\"nofollow\"> CSS Shape.<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<div class=\"ref-block ref-block--post\" id=\"ref-post-1\">\n\t\t\t\t\t<a href=\"https:\/\/www.hongkiat.com\/blog\/change-default-text-wrapping-html-css\/\" class=\"ref-block__link\" title=\"Read More: How to Change Default Text Wrapping with HTML and CSS\" rel=\"bookmark\"><span class=\"screen-reader-text\">How to Change Default Text Wrapping with HTML and CSS<\/span><\/a>\n<div class=\"ref-block__thumbnail img-thumb img-thumb--jumbo\" data-img='{ \"src\" : \"https:\/\/assets.hongkiat.com\/uploads\/thumbs\/250x160\/change-default-text-wrapping-html-css.jpg\" }'>\n\t\t\t\t\t\t\t<noscript>\n<style>.no-js #ref-block-post-39226 .ref-block__thumbnail { background-image: url(\"https:\/\/assets.hongkiat.com\/uploads\/thumbs\/250x160\/change-default-text-wrapping-html-css.jpg\"); }<\/style>\n<\/noscript>\n\t\t\t\t\t\t<\/div>\n<div class=\"ref-block__summary\">\n<h4 class=\"ref-title\">How to Change Default Text Wrapping with HTML and CSS<\/h4>\n<p class=\"ref-description\">\n\t\t\t\t\t\tUnlike paper, web pages can almost infinitely extend sideways. As much as impressive that is, it's not something...\t\t\t\t\t\t<span>Read more<\/span><\/p>\n<\/div>\n<\/div>\n<h2>Mandatory fields<\/h2>\n<p>If you got a form there is a high chance that some fields in it are required while others aren\u2019t. You will need to let the users know which is which. The CSS for this is <strong>:required<\/strong> <strong>:optional<\/strong> pseudo classes. All modern browsers support them.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"EjxJLB\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"EjxJLB\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/EjxJLB\/\" rel=\"nofollow\"> EjxJLB<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Picky with colors<\/h2>\n<p>If you don\u2019t like a certain color, like blue, we can color the selected area with some other color and the <strong><code>::selection<\/code><\/strong> pseudo element is the CSS for that. This is supported by all modern browsers.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"eNYoPo\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"eNYoPo\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/eNYoPo\/\" rel=\"nofollow\"> eNYoPo<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Did I check it?<\/h2>\n<p>In a situation where a checkbox has been checked, it would be nice to have another indication apart form the tiny checkmark inside the default checkbox to denote that the item has been checked.<\/p>\n<p>There is CSS for that which exploits the bond between the immediate siblings, two elements side by side. CSS has adjacent sibling selector denoted by the plus <strong>+<\/strong> sign,and we can use it to to target the label beside the checkbox. But what about targetting the checked checkbox first? There is the <strong>:checked<\/strong> pseudo class for that.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"BNaEOm\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"BNaEOm\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/BNaEOm\/\" rel=\"nofollow\"> BNaEOm<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Like a storybook<\/h2>\n<p>Then, wouldn\u2019t it be nice if the first \u201cO\u201d in the \u201cOnce upon a time\u201d looks pretty? We can make it look pretty, after all there is CSS for that. Here is where <strong>::first-letter<\/strong> pseudo element comes to the rescue. It targets the first letter of the first line of the targeted element. Read more about it <a href=\"https:\/\/www.hongkiat.com\/blog\/css-better-paragraph\/\">here<\/a>.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"bdGPWd\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"bdGPWd\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/bdGPWd\/\" rel=\"nofollow\"> bdGPWd<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Would you like to know more?<\/h2>\n<p>An element may have class X or data Y or some other value to an attribute. If we ever need to display such an attribute value of an element near it, we can use the <strong>content:attr(X)<\/strong>. It retrieves the value of attribute X of the element, then we can show it beside the element.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"bdGXWr\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"bdGXWr\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/bdGXWr\/\" rel=\"nofollow\"> bdGXWr<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>A little bit more to the left<\/h2>\n<p>Centering elements for CSS beginners is quite a feat. Different elements require different set of CSS properties to center them. We will look into one example out of many that is available in the world wide web, so that you can remember again that there is <a href=\"https:\/\/www.hongkiat.com\/blog\/css-tricks-vertical-align-content\/\">CSS to center things<\/a>.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"css,result\" data-user=\"rpsthecoder\" data-slug-hash=\"jPEEmZ\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"jPEEmZ\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/jPEEmZ\/\" rel=\"nofollow\"> jPEEmZ<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Disclose file format of links<\/h2>\n<p>Ever seen a small image near a link indicating what that link is? A PDF? or a DOC? Yes, there is CSS to achieve that. The <strong>content:url()<\/strong> is what we will use to display the image behind the links.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"css,result\" data-user=\"rpsthecoder\" data-slug-hash=\"gpbbKW\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"gpbbKW\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/gpbbKW\/\" rel=\"nofollow\"> gpbbKW<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>Trigger parallax effect<\/h2>\n<p>The <a href=\"https:\/\/www.hongkiat.com\/blog\/parallax-scrolling-wordpress-themes\/\">parallax effect<\/a> is an effect used to describe the seemingly slow movement of background relative to the foreground. This effect is popular in websites which <a href=\"https:\/\/www.hongkiat.com\/blog\/web-design-scrolling\/\">implement parallax scrolling<\/a>.  There are different ways to implement it, the example below works in Firefox with <strong>background-attachment: fixed;<\/strong>.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"html,result\" data-user=\"rpsthecoder\" data-slug-hash=\"XbJJaO\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"XbJJaO\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/XbJJaO\/\" rel=\"nofollow\"> XbJJaO<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<h2>The power of CSS animations<\/h2>\n<p>Probably not a huge \u201cthere is CSS for that\u201d moment, because you all are most probably aware of <a href=\"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/\">CSS animations<\/a> by now. But a little reminder is of no harm. There are many <a href=\"https:\/\/www.hongkiat.com\/blog\/creative-css-animations\/\">uses for CSS animations<\/a> but here is one for a simple coloring exercise.<\/p>\n<p class=\"codepen\" data-height=\"265\" data-theme-id=\"0\" data-default-tab=\"css,result\" data-user=\"rpsthecoder\" data-slug-hash=\"Jdooyg\" style=\"height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-pen-title=\"Jdooyg\"> <span>See the Pen <a href=\"https:\/\/codepen.io\/rpsthecoder\/pen\/Jdooyg\/\" rel=\"nofollow\"> Jdooyg<\/a> by Preethi Sam (<a href=\"https:\/\/codepen.io\/rpsthecoder\" rel=\"nofollow\">@rpsthecoder<\/a>)\n  on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>.<\/span><\/p>\n<p><script async src=\"https:\/\/static.codepen.io\/assets\/embed\/ei.js\"><\/script> <\/p>","protected":false},"excerpt":{"rendered":"<p>If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code something and realised after a bit of googling, that \u201cthere is CSS for that\u201d. If you hadn\u2019t, well you are about to. This&hellip;<\/p>\n","protected":false},"author":145,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[507,4501],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>15 Useful CSS Tricks You Might Have Overlooked - Hongkiat<\/title>\n<meta name=\"description\" content=\"If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"15 Useful CSS Tricks You Might Have Overlooked\" \/>\n<meta property=\"og:description\" content=\"If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-14T15:32:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-23T09:28:20+00:00\" \/>\n<meta name=\"author\" content=\"Preethi Ranjit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Preethi Ranjit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/\"},\"author\":{\"name\":\"Preethi Ranjit\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\"},\"headline\":\"15 Useful CSS Tricks You Might Have Overlooked\",\"datePublished\":\"2019-05-14T15:32:02+00:00\",\"dateModified\":\"2020-06-23T09:28:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/\"},\"wordCount\":1260,\"commentCount\":25,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"keywords\":[\"CSS\",\"CSS Tutorials\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/\",\"name\":\"15 Useful CSS Tricks You Might Have Overlooked - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"datePublished\":\"2019-05-14T15:32:02+00:00\",\"dateModified\":\"2020-06-23T09:28:20+00:00\",\"description\":\"If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-css-tricks-you-might-have-overlooked\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"15 Useful CSS Tricks You Might Have Overlooked\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\",\"name\":\"Preethi Ranjit\",\"description\":\"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/preethi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"15 Useful CSS Tricks You Might Have Overlooked - Hongkiat","description":"If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/","og_locale":"en_US","og_type":"article","og_title":"15 Useful CSS Tricks You Might Have Overlooked","og_description":"If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code","og_url":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2019-05-14T15:32:02+00:00","article_modified_time":"2020-06-23T09:28:20+00:00","author":"Preethi Ranjit","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Preethi Ranjit","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/"},"author":{"name":"Preethi Ranjit","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3"},"headline":"15 Useful CSS Tricks You Might Have Overlooked","datePublished":"2019-05-14T15:32:02+00:00","dateModified":"2020-06-23T09:28:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/"},"wordCount":1260,"commentCount":25,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"keywords":["CSS","CSS Tutorials"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/","url":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/","name":"15 Useful CSS Tricks You Might Have Overlooked - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"datePublished":"2019-05-14T15:32:02+00:00","dateModified":"2020-06-23T09:28:20+00:00","description":"If you have been a frontend web developer for a while, there is a high chance that you have had a moment when you were trying to find out how to code","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/useful-css-tricks-you-might-have-overlooked\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"15 Useful CSS Tricks You Might Have Overlooked"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3","name":"Preethi Ranjit","description":"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.","url":"https:\/\/www.hongkiat.com\/blog\/author\/preethi\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-6di","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/23888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/145"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=23888"}],"version-history":[{"count":4,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/23888\/revisions"}],"predecessor-version":[{"id":51412,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/23888\/revisions\/51412"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=23888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=23888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=23888"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=23888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}