--- url: "https://web.dev/articles/codelab-centering-in-css" titulek: "Codelab: Centering in CSS | Articles | web.dev" h1: "Codelab: Centering in CSS Stay organized with collections Save and categorize content based on your preferences." popis: "Learn 5 different centering techniques with CSS." jazyk: "en" kanonicka: "https://web.dev/articles/codelab-centering-in-css" drobecky: ["Articles", "Codelab: Centering in CSS"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 23:13:10" znaku: 1695 slov: 258 kodovani: "iso-8859-2" sha256: "bde69b1674669d8951b94c7ae51b615adf31b993352cdab92600b6aed1933c19" --- Codelab: Centering in CSS Stay organized with collections Save and categorize content based on your preferences. Adam Argyle This codelab sets you up to share and showcase your favorite way of centering in CSS. Check out my blog post [Centering in CSS](/articles/centering-in-css) to learn about 5 of my favorite ways to center in CSS. Or watch this video! Setup Click **Remix to Edit** to make the project editable. Open `app/index.html` At `line 23`, replace `/* your centering CSS here /*` with your CSS (optional) Name your centering technique and replace the text in the `

` Styles Create a new file in the `app/css/` folder Create a selector to hold your centering solution, like `.turbo-center` or `[floaty-mcfloat]` Within that new selector, write your centering technique (feel free to look at the other's in `app/css/` as examples) (optional) write some "support styles" so we can see which children need styles to support the centering Open `app/css/index.css` and import your new file at the bottom Tie it all up Open `app/index.html` again Find the `
` and give it your custom selector you made in step #2 of the previous section. [Tweet me](https://twitter.com/argyleink) your Glitch and I'll feature it on the blog post! Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2020-12-16 UTC.