{"id":24905,"date":"2020-06-16T21:13:25","date_gmt":"2020-06-16T13:13:25","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=24905"},"modified":"2020-06-16T17:48:21","modified_gmt":"2020-06-16T09:48:21","slug":"css-floats","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/css-floats\/","title":{"rendered":"CSS Floats Explained in Five Questions"},"content":{"rendered":"<p>CSS \"Floats\" (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If you have ever come across the problems of vanishing nearby elements or floats that poke out like a sore thumb, worry no more.<\/p>\n<p>This post covers five basic questions that will help you become an expert at floating elements.<\/p>\n<ol>\n<li><a href=\"#Which_elements_dont_float\">Which elements don\u2019t float?<\/a><\/li>\n<li><a href=\"#What_happens_to_an_element_when_it_floats\">What happens to an element when it floats?<\/a><\/li>\n<li><a href=\"#What_happens_to_Floats_siblings\">What happens to the siblings of \"Floats\"?<\/a><\/li>\n<li><a href=\"#What_happens_to_a_parent_of_a_Float\">What happens to a parent of a \"Float\"?<\/a><\/li>\n<li><a href=\"#How_to_clear_Floats\">How do you clear \"Floats\"?<\/a><\/li>\n<\/ol>\n<p>For readers who addopt the TL;dr approach to life, there\u2019s a summary near the end of the post.<\/p>\n<h2 id=\"Which_elements_dont_float\">1. Which elements don\u2019t float?<\/h2>\n<p>An <strong>absolute<\/strong> or <strong>fixed positioned element<\/strong> won\u2019t float. So the next time you encounter a float that isn\u2019t working, check if it is in <code>position:absolute<\/code> or <code>position:fixed<\/code> and apply changes accordingly.<\/p>\n<h2 id=\"What_happens_to_an_element_when_it_floats\">2. What happens to an element when it floats?<\/h2>\n<p>When an element is tagged \"float\" it runs to either the left or the right basically until it <strong>hits the wall of its container element<\/strong>. Alternatively, it will run until it <strong>hits another floating element that has already hit the same wall. <\/strong>They\u2019ll keep piling up side by side until the space runs out, and newer incoming ones will be moved down.<\/p>\n<p>Floating elements also <strong>won\u2019t go above the elements <em>before<\/em> it<\/strong> in the code, something you need to consider before coding a \u201cFloat\u201d <em>after<\/em> an element to the side of which you want to float it.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/float-below-others.jpg?newedit\" alt=\"float below others\" width=\"516\" height=\"283\"><\/figure>\n<p>Here are two more things that happen to a floating element depending on what type of element is being kept floating:<\/p>\n<h3>An inline element will turn into a block-level element when floated<\/h3>\n<p>Ever wondered why suddenly you\u2019re able to assign height & width to a floating <code>span<\/code>? That\u2019s because all the elements when floated will get the value <code>block<\/code> for its <code>display<\/code> attribute (<code>inline-table<\/code> will get <code>table<\/code>) making them block level elements.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/floating-span.jpg?newedit\" alt=\"floating span\" width=\"417\" height=\"181\"><\/figure>\n<h3>A block element of unspecified width will shrink to fit its content when floated<\/h3>\n<p>Usually, when you don\u2019t specify width to a block element, its width is the default 100%. But when floated, that\u2019s no more the case; the block element\u2019s box will shrink until its contents remain visible.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/floating-div.jpg?newedit\" alt=\"floating div\" width=\"318\" height=\"182\"><\/figure>\n<h2 id=\"What_happens_to_Floats_siblings\">3. What happens to The Siblings of \"Floats\"?<\/h2>\n<p>When you decide to float an element among a bunch of elements don\u2019t worry about how it\u2019s going to behave, its behavior will be predictable and will either move left or right. What you should really be thinking about is <strong>how the siblings after it are going to behave<\/strong>.<\/p>\n<p>\"Floats\" have the most caring and obedient later siblings in the entire world. They\u2019ll do everything in their power to accommodate a floating element.<\/p>\n<p>The <strong>text and inline elements <\/strong>will simply<strong> make way for the \"Floats\" and will surround the \"Float\"<\/strong> when it\u2019s in position.<\/p>\n<p>The <strong>block elements <\/strong>will go a step further and will<strong> wrap themselves around a \"Float\"<\/strong> generously, even if it means kicking out their own child elements to make space for the \"Float\".<\/p>\n<p>Let\u2019s check this out in an experiment. Below are a blue box and after it is a red box of the same size with some child elements.<\/p>\n<p><iframe height=\"261\" scrolling=\"no\" src=\"https:\/\/codepen.io\/rpsthecoder\/embed\/jbVKJz\/?height=261&theme-id=12825&default-tab=result\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\"><\/iframe><\/p>\n<p>Now, let\u2019s float the blue box, and see what happens to the red box and its children.<\/p>\n<p><iframe height=\"261\" scrolling=\"no\" src=\"https:\/\/codepen.io\/rpsthecoder\/embed\/BoQVeZ\/?height=261&theme-id=12825&default-tab=result\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\"><\/iframe><\/p>\n<p>Everything will be fine once the red box stops embracing the blue box and for that you can use <code>overflow:hidden<\/code>.<\/p>\n<p><strong>When you add <code>overflow:hidden<\/code> to an element that has been wrapping a float, it\u2019ll stop doing so<\/strong>. See below how the red box behaves with <code>overflow:hidden<\/code>.<\/p>\n<p><iframe height=\"261\" scrolling=\"no\" src=\"https:\/\/codepen.io\/rpsthecoder\/embed\/jbVKjx\/?height=261&theme-id=12825&default-tab=result\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\"><\/iframe>\n<iframe height=\"261\" scrolling=\"no\" src=\"https:\/\/codepen.io\/rpsthecoder\/embed\/avBKPx\/?height=261&theme-id=12825&default-tab=result\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\"><\/iframe><\/p>\n<h2 id=\"What_happens_to_a_parent_of_a_Float\">4. What happens to a parent of a \"Float\"?<\/h2>\n<p>Parents don\u2019t care much about their \"Float\" children, except that they shouldn\u2019t go out of their left or right boundaries.<\/p>\n<p>Typically a block element of unspecified height increases its height to accommodate its child elements, but that isn\u2019t the case for \"Float\" children. <strong>If a \"Float\u2019s\" size increases, its parent won\u2019t increase its height accordingly<\/strong>. This again can be solved by using <code>overflow:hidden<\/code> in the parent.<\/p>\n<p><iframe height=\"261\" scrolling=\"no\" src=\"https:\/\/codepen.io\/rpsthecoder\/embed\/jbVpOK\/?height=261&theme-id=12825&default-tab=result\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\"><\/iframe><\/p>\n<h2 id=\"How_to_clear_Floats\">5. How to clear \"Floats\"?<\/h2>\n<p>I\u2019ve already mentioned using <code>overflow:hidden<\/code> to make a parent height-wise accommodate a floating child while creating the right space for other elements after the \"Float\" and to stop siblings from wrapping \"Floats.<\/p>\n<p>And that\u2019s how you make an element live near a \"Float\" with no compromises.<\/p>\n<p>There\u2019s another method where the elements won\u2019t even be anywhere near their \"Float\" siblings. By using the <code>clear<\/code> attribute you can make an element free from being near a \"Float\".<\/p>\n<pre>clear: left; \r\nclear: right;\r\nclear: both;\r\n<\/pre>\n<p><code>left<\/code> value clears all \"Floats\" to the left of the element, and vice versa for <code>right<\/code>, and on both sides for <code>both<\/code>. This <code>clear<\/code> attribute can be used on a sibling, empty div or on pseudo element as per your convenient.<\/p>\n<h2 id=\"summary\">Summary<\/h2>\n<ol>\n<li>Absolute\/Fixed elements won\u2019t float.<\/li>\n<li>A \"Float\" doesn\u2019t go above the element <em>before<\/em> it in the code.<\/li>\n<li>If there is not enough space in the container, a \"Float\" will be pushed down.<\/li>\n<li>All \"Floats\" are made into block-level elements.<\/li>\n<li>If width is not specified on a \"Float\", it\u2019ll shrink to fit the content.<\/li>\n<li>The later siblings of a \"Float\" will either surround them (inline & text) or wrap them (blocks).<\/li>\n<li>To stop an element from wrapping a \"Float\", use <code>overflow:hidden<\/code>.<\/li>\n<li>The parents of a \"Float\"s would not increase its height to fit the float.<\/li>\n<li>To make a parent increase its height as per the \"Float\", use <code>overflow:hidden<\/code> (or create an empty sibling with <code>clear<\/code> after it).<\/li>\n<li>To prevent an element being near any \"Float\" use the <code>clear<\/code> attribute.<\/li>\n<\/ol>","protected":false},"excerpt":{"rendered":"<p>CSS &#8220;Floats&#8221; (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If you have ever come across the problems of vanishing nearby elements or floats that poke out like a sore thumb, worry no more. This post covers five basic questions that will&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.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>CSS Floats Explained in Five Questions - Hongkiat<\/title>\n<meta name=\"description\" content=\"CSS &quot;Floats&quot; (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If\" \/>\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\/css-floats\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Floats Explained in Five Questions\" \/>\n<meta property=\"og:description\" content=\"CSS &quot;Floats&quot; (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/css-floats\/\" \/>\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=\"2020-06-16T13:13:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/float-below-others.jpg?newedit\" \/>\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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/\"},\"author\":{\"name\":\"Preethi Ranjit\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\"},\"headline\":\"CSS Floats Explained in Five Questions\",\"datePublished\":\"2020-06-16T13:13:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/\"},\"wordCount\":968,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-floats\\\/float-below-others.jpg?newedit\",\"keywords\":[\"CSS\",\"CSS Tutorials\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/\",\"name\":\"CSS Floats Explained in Five Questions - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-floats\\\/float-below-others.jpg?newedit\",\"datePublished\":\"2020-06-16T13:13:25+00:00\",\"description\":\"CSS &quot;Floats&quot; (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-floats\\\/float-below-others.jpg?newedit\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-floats\\\/float-below-others.jpg?newedit\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-floats\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS Floats Explained in Five Questions\"}]},{\"@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":"CSS Floats Explained in Five Questions - Hongkiat","description":"CSS &quot;Floats&quot; (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If","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\/css-floats\/","og_locale":"en_US","og_type":"article","og_title":"CSS Floats Explained in Five Questions","og_description":"CSS &quot;Floats&quot; (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If","og_url":"https:\/\/www.hongkiat.com\/blog\/css-floats\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2020-06-16T13:13:25+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/float-below-others.jpg?newedit","type":"","width":"","height":""}],"author":"Preethi Ranjit","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Preethi Ranjit","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/"},"author":{"name":"Preethi Ranjit","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3"},"headline":"CSS Floats Explained in Five Questions","datePublished":"2020-06-16T13:13:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/"},"wordCount":968,"commentCount":7,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/float-below-others.jpg?newedit","keywords":["CSS","CSS Tutorials"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/css-floats\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/","url":"https:\/\/www.hongkiat.com\/blog\/css-floats\/","name":"CSS Floats Explained in Five Questions - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/float-below-others.jpg?newedit","datePublished":"2020-06-16T13:13:25+00:00","description":"CSS &quot;Floats&quot; (floating elements) are simple to use but once used, the effect it has on the elements around it sometimes get unpredictable. If","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/css-floats\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/float-below-others.jpg?newedit","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-floats\/float-below-others.jpg?newedit"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/css-floats\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"CSS Floats Explained in Five Questions"}]},{"@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-6tH","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/24905","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=24905"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/24905\/revisions"}],"predecessor-version":[{"id":50671,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/24905\/revisions\/50671"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=24905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=24905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=24905"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=24905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}