Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <style> /* Base button style */ .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; /* Space between text and icon */ padding: 10px 20px; border: 2px solid transparent; border-radius: 5px; font-size: 1rem; font-weight: 500; text-decoration: none; cursor: pointer; font-family: inherit; /* Inherit the form's font */ transition: all 0.2s ease-in-out; } .btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.4); } .btn .icon { width: 18px; height: 18px; } .btn-block { width: 100%; display: flex; /* Overrides inline-flex */ } /* -- Button Color Variants -- */ /* Primary Button (e.g., Submit, Save) */ .btn-primary { background-color: #007bff; color: white; } .btn-primary:hover { background-color: #0069d9; } /* Secondary Button (e.g., Cancel, Back) */ .btn-secondary { background-color: #6c757d; color: white; } .btn-secondary:hover { background-color: #5a6268; } /* Outline Button (a less prominent style) */ .btn-outline { background-color: transparent; border-color: #007bff; color: #007bff; } .btn-outline:hover { background-color: #007bff; color: white; } /* Danger Button (e.g., Delete) */ .btn-danger { background-color: #dc3545; color: white; } .btn-danger:hover { background-color: #c82333; } /* Disabled State */ .btn:disabled { background-color: #e9ecef; color: #6c757d; cursor: not-allowed; border-color: #dee2e6; } /* Container and Form styles */ .button-form-container { max-width: 600px; margin: 30px auto; padding: 30px; border-radius: 8px; background-color: #f8f9fa; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; /* Consistent font */ } .form-group { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid #dee2e6; } .form-group:last-of-type { border-bottom: none; margin-bottom: 0; } .form-group h3 { margin-top: 0; font-weight: 600; } .form-group .buttons { display: flex; flex-wrap: wrap; gap: 15px; align-items: center;} </style> <div class="button-form-container"> <!-- Everything is wrapped in a <form> element --> <form action="#" method="post"> <div class="form-group"> <h3>Standard Actions</h3> <div class="buttons"> <!-- Use type="submit" for the primary action --> <button type="submit" class="btn btn-primary">Save Changes</button> <!-- Use type="reset" for a cancel action that resets form fields --> <button type="reset" class="btn btn-secondary">Cancel</button> </div> </div> <div class="form-group"> <h3>Alternative & Destructive Actions</h3> <div class="buttons"> <button type="button" class="btn btn-outline">Export Data</button> <button type="button" class="btn btn-danger">Delete Account</button> </div> </div> <div class="form-group"> <h3>Buttons with Icons</h3> <div class="buttons"> <button type="button" class="btn btn-primary"> <svg class="icon" viewBox="0 0 24 24" fill="currentColor"><path d="M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z"></path></svg> Download </button> <button type="button" class="btn btn-danger"> <svg class="icon" viewBox="0 0 24 24" fill="currentColor"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"></path></svg> Delete </button> </div> </div> <div class="form-group"> <h3>Disabled State</h3> <div class="buttons"> <button type="submit" class="btn btn-primary" disabled>Submit (Disabled)</button> </div> </div> <div class="form-group"> <h3>Full-Width Block Button</h3> <div class="buttons"> <button type="submit" class="btn btn-primary btn-block">Register Full Account</button> </div> </div> </form> </div>