How to Change Button Size in HTML?
Last Updated :
17 Oct, 2024
To change the size of a button in HTML, there are several methods such as using the style attribute, external CSS, or adjusting the padding and font size. Modifying the button’s size enhances both the visual design and the user experience of a website.
Here are three approaches to changing the size of a button in HTML:
Different Ways to Change Button Size
1. Using Style Attribute
This approach involves using the style attribute directly within the button element to define its width and height. This method allows you to apply styling directly in the HTML file.
Example: Implementation of Changing button size in HTML using Style Attribute.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Button Size</title>
</head>
<body>
<button style="width: 200px; height: 50px;">
Click Me!
</button>
</body>
</html>
Output:

2. Using External CSS
In this approach, the HTML file links to an external CSS file. Within this CSS file, the ".large-button" class is defined, setting the button's width to 200 pixels, height to 50 pixels, and background color to a shade of green. This styling applies to the button in the HTML body, resulting in a larger-sized button with a green background.
Example: Implementation of Changing button size in HTML using External CSS.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Button Size</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<button class="large-button">
Click Me!
</button>
</body>
</html>
CSS
.large-button {
width: 200px;
height: 50px;
background-color: rgb(170, 218, 202);
}
Output:
Using External CSS3. Using Internal CSS
In this approach, the padding and the font size properties are used to change button size in HTML. The padding property is used to increase the space inside the button, effectively making it larger. Here, 20px padding is added to the top and bottom, and 40px padding is added to the left and right. The font-size property is used to increase the size of the text inside the button.
Example: Implementation of Changing button size in HTML using Padding and Font Size.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Button Size</title>
<style>
.large-button {
padding: 12px 70px;
font-size: 16px;
border-radius: 10px;
border: 2px solid black;
background-color: pink;
}
</style>
</head>
<body>
<button class="large-button">
Click Me!
</button>
</body>
</html>
Output:
Using Internal CSS
Similar Reads
How to Change the Button Color in HTML ? Styling of elements enhances the visual appearance and improves the overall user interface. We can change the button color in HTML using different approaches as listed below. Table of Content Using Inline StylingUsing Internal StylingChange the Button Color Using Inline StylingIn this approach, we a
3 min read
How to Add Button in HTML? Buttons in HTML are interactive elements that users can click to trigger certain actions, such as submitting forms, navigating to different pages, or executing JavaScript functions. We can use either the <button> tag or <input type="button"> tag to create a button.1. Using <button>
1 min read
How to add icons in the button in HTML ? Adding icons in buttons in HTML involves including visual symbols or images within buttons to enhance their appearance and usability. This can be done using icon libraries like Font Awesome, Bootstrap Icons, or Material Icons, or by inserting images directly with <img> tags for visual cues.Add
3 min read
How to create a clickable button in HTML ? In this article, we will create a Button by using the <Button> Element in the Document. It is used to submit the content. The images and text content can use inside a button tag. Syntax: <button type = "button"> Example: Using HTML <button> type Attribute html <!DOCTYPE html>
1 min read
How to Add Button Inside an Input Field in HTML ? Integrating a button inside an input box is a common design pattern in web development, often seen in search bars, where a âsearchâ button sits within the text input field, or in password fields that include a âshow/hideâ toggle. This UI element enhances user experience by offering a clear, interact
3 min read
How to Change an Input Button Image using CSS? Changing an input button image using CSS allows developers to replace the default button style with a custom image. This enhances the button's appearance and improves user interaction. CSS properties like background-image and hover effects enable dynamic and visually appealing button designs for web
2 min read