Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the size of button in HTML

Tags:

html

button

I have some buttons on my pure HTML/JS page. When the page is opened in browser, the button size is normal. But on refresh/reloading page, the button size is reduced. In fact, I have not set the button text value. The button's text is blank. How should I set the size of my button in HTML irrespective to the size of the text?

like image 845
AdityaK Avatar asked Jul 29 '14 12:07

AdityaK


People also ask

How do I change the size of a button in HTML?

Editing the size of a button in HTML is relatively easy. In the simplest form you just have to add a 'style' attribute to the button element containing your desired height and width values in pixels. It goes something like this. Alternatively, you can add a 'class' to button and add your styles in a CSS file.

How do you increase the size of a button tag in HTML?

style. height = '200px'; myButton. style. width= '200px';

How do I make a button full size?

display: block and width: 100% is the correct way to go full width but you need to remove the left/right margin on the button as it pushes it outside the containing element. for more information on the box-sizing property, read the MDN docs.


2 Answers

Do you mean something like this?

HTML

<button class="test"></button> 

CSS

.test{     height:200px;     width:200px; } 

If you want to use inline CSS instead of an external stylesheet, see this:

<button style="height:200px;width:200px"></button> 
like image 155
Gab Avatar answered Sep 30 '22 07:09

Gab


This cannot be done with pure HTML/JS, you will need CSS

CSS:

button {      width: 100%;      height: 100%; } 

Substitute 100% with required size

This can be done in many ways

like image 37
Lemuel Botha Avatar answered Sep 30 '22 06:09

Lemuel Botha