{"id":3149,"date":"2020-02-24T13:18:34","date_gmt":"2020-02-24T13:18:34","guid":{"rendered":"https:\/\/rengga.dev\/blog\/?p=3149"},"modified":"2023-03-02T10:12:55","modified_gmt":"2023-03-02T10:12:55","slug":"css-tutorial-is-css-float-deprecated","status":"publish","type":"post","link":"https:\/\/rengga.dev\/blog\/css-tutorial-is-css-float-deprecated\/","title":{"rendered":"CSS Tutorial &#8211; Is CSS float deprecated?"},"content":{"rendered":"<p><span style=\"color: #ef3207;\"><a style=\"color: #ef3207;\" href=\"https:\/\/rengga.dev\/\" target=\"_blank\" rel=\"noopener\"><strong>Rengga Dev<\/strong><\/a> <\/span>&#8211; An interesting conversation came up at work the other day: Should we use the CSS\u00a0<code>float<\/code>\u00a0property now that we have CSS Grid and Flexbox?<\/p>\n<h2 id=\"h-the-short-answer\"><a id=\"aa-the-short-answer\" class=\"aal_anchor\" href=\"https:\/\/css-tricks.com\/is-css-float-deprecated\/#aa-the-short-answer\" aria-hidden=\"true\"><\/a>The short answer<\/h2>\n<p>No! Well, mostly. I\u2019d only use it today for wrapping text around images, though and I\u2019d avoid using\u00a0<code>float<\/code>\u00a0entirely for layouts.<\/p>\n<h2 id=\"h-the-longer-more-annoying-answer\"><a id=\"aa-the-longer-more-annoying-answer\" class=\"aal_anchor\" href=\"https:\/\/css-tricks.com\/is-css-float-deprecated\/#aa-the-longer-more-annoying-answer\" aria-hidden=\"true\"><\/a>The longer, more annoying answer<\/h2>\n<p>Before flexbox and grid, we had to use the CSS\u00a0<code>float<\/code>\u00a0property to make grids and layouts. In fact, it was the first thing I learned about web design. On one hot summer afternoon I cracked open a copy of\u00a0<em>Designing with Web Standards<\/em>\u00a0by Jeffrey Zeldman and then moved a tiny red div with\u00a0<code>float: right<\/code>. It was magic. There was\u00a0<em>power<\/em>\u00a0in the\u00a0<code>float<\/code>.<\/p>\n<p>It was so easy to move something around on the screen that I now wonder how many designers fell in love with the web simply because of how easy it is to use move things around like that.<\/p>\n<p>But using\u00a0<code>float<\/code>\u00a0to build complex layouts was\u00a0<a href=\"https:\/\/alistapart.com\/article\/journey\/#section15\" rel=\"noopener\">always a hack<\/a>: it was only really designed to let text wrap around an image.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">img {\r\n  width: 150px;\r\n  float: left;\r\n}<\/pre>\n<p><iframe style=\"width: 100%;\" title=\"Floating Image\" src=\"https:\/\/codepen.io\/renggagumilar\/embed\/ExEJRwZ?default-tab=result&amp;theme-id=dark\" height=\"400\" frameborder=\"no\" scrolling=\"no\" allowfullscreen=\"allowfullscreen\"><br \/>\nSee the Pen <a href=\"https:\/\/codepen.io\/renggagumilar\/pen\/ExEJRwZ\"><br \/>\nFloating Image<\/a> by Rengga Gumilar (<a href=\"https:\/\/codepen.io\/renggagumilar\">@renggagumilar<\/a>)<br \/>\non <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<br \/>\n<\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rengga Dev &#8211; An interesting conversation came up at work the other <a class=\"read-more\" href=\"https:\/\/rengga.dev\/blog\/css-tutorial-is-css-float-deprecated\/\" title=\"CSS Tutorial &#8211; Is CSS float deprecated?\" itemprop=\"url\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":3954,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[308,268,197,103,227],"newstopic":[],"class_list":{"0":"post-3149","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-html-css","8":"tag-css-float","9":"tag-css-grid","10":"tag-css-tutorial","11":"tag-web-design","12":"tag-web-designer"},"_links":{"self":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/comments?post=3149"}],"version-history":[{"count":1,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3149\/revisions"}],"predecessor-version":[{"id":3150,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3149\/revisions\/3150"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media\/3954"}],"wp:attachment":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media?parent=3149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/categories?post=3149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/tags?post=3149"},{"taxonomy":"newstopic","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/newstopic?post=3149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}