The CSS float property is used to set or return the horizontal alignment of elements. But this property allows an element to float only right or left side of the parent body with rest of the elements wrapped around it. There is no way to float center in CSS layout. So, we can center the elements by using position property.
Example 1: This example set the position of elements exactly at the center of the screen.
Example: This example set the position of text float elements exactly at the center of the screen.
- How to make an image center-aligned (vertically & horizontally) inside a bigger div using CSS?
- HTML | center Tag
- How to horizontally center a using CSS?
- How to vertically center text with CSS?
- CSS Float
- p5.js | float() function
- Comparing float value in PHP
- Graph measurements: length, distance, diameter, eccentricity, radius, center
- Bootstrap | Float utilities with Examples
- How to float three div side by side using CSS?
- How to make a redirect in PHP?
- How to make div not larger than its contents using CSS?
- How to make a placeholder for a 'select' box?
- How to make text input non-editable using CSS?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.