Set the width of a button with CSS

To set the button width, use the CSS width property.


You can try to run the following code to set the width of a button −

Live Demo

<!DOCTYPE html>
         .btn {
            background-color: yellow;
            color: black;
            width: 120px;
            text-align: center;
            font-size: 15px;
            padding: 20px;
            border-radius: 15px;
            border: 3px dashed blue;
      <p>Click below for result:</p>
      <button class = "btn">Result</button>

Updated on: 03-Jul-2020

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started