How to center a button in CSS?26 Mar 2025 | 2 min read CSS is mainly used for providing the best style to the HTML web page. Using CSS, We can specify the arrangement of elements on the page. There are various methods of aligning the button at the center of the web page. We can align the buttons horizontally as well as vertically. We can center the button by using the following methods:
Let's understand the above methods by using some illustrations. ExampleIn this example, we are using the text-align property and set its value to the center. It can either be placed in a body tag or in the parent div tag of the element. Here, we place the text-align: center; in the parent div tag of the button element. Output ![]() ExampleIn this example, we are using the display: grid; property, and margin: auto; property. Here, we place the display: grid; in the parent div tag of the button element. The button will place at the center of the horizontal and vertical positions. Output ![]() ExampleIt is another example of placing the button at the center. In this example, we are using the display: flex; property, justify-content: center; property, and align-items: center; property. This example will help us to place the button at the center of the horizontal and vertical positions. Output ![]() Next TopicHow to change background color in CSS |
In this article, we will understand the marquee effect with the help of CSS. What do you mean by Marquee? Marquee is used to create horizontal or vertical scrolling effect, animation effect in text and images for web pages. For Example: News headlines moves in TV. The <marquee>...
10 min read
In this article, we will create a CSS shake effect on text and image. In the beginning, we will learn the basic meaning of CSS. After that, we will learn this concept with the help of various examples. What do you mean by CSS? The term CSS stands...
7 min read
In this article, we will understand the .A time table is a Schedule of meeting, schools, colleges and conference etc. A CSS Grid is a powerful tool that allows for two-dimensional layouts to be created on the web. Following are the examples of timetable template using...
12 min read
What is Div and Why Center a Div? In short, a div is known for the content division element. It is a generic block-level element in HTML. With the help of Div, we can divide the web page into different sections to target each section with the...
10 min read
The abbreviated term CSS refers to Cascading Style Sheets. Managing the appearance and layout of HTML (Hypertext Markup Language) documents is a key technique in web development. CSS enables web designers to apply styles to HTML components, giving websites their visual look. Styles include colors, fonts,...
4 min read
Freelate One of the primary methods for applying styles to HTML components is using CSS type selectors. A type selector uses the name of the HTML tag to target specific items. It enables you to add styles to any element in your HTML page that uses a...
4 min read
Introduction to Styling: CSS form styling is an essential component of website development that focuses on modifying HTML form's appearance and user experience in general by using Cascading Style Sheets (CSS). Forms are crucial components of web applications because they let users enter and submit data....
9 min read
A CSS framework is a pre-prepared set of styles and layouts one can utilize to improve the appearance of your website without having to start from scratch. It works like a series of templates one can utilize to design a website rapidly. Think about planning to construct...
6 min read
What is CSS Portal? A feature introduced in the CSS Containment specification is called a "portal" in CSS. By enabling developers to isolate specific page elements from the rest of the page, CSS Containment gives them greater control over how quickly web pages render by limiting the...
4 min read
Introduction to CSS Rotation Definition and Purpose: HTML elements can be rotated around a predetermined point using CSS rotation, a transformation property. It is a component of CSS Transform, a potent feature that allows different visual transformations on elements without changing how they are laid out in the...
8 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India