How to create: Text button

Learn how to use CSS to set the style of text buttons.

How to set the style of text buttons

Step 1 - Add HTML:

<button class="btn success">Success</button>
<button class="btn info">Info</button>
<button class="btn warning">Warning</button>
<button class="btn danger">Danger</button>
<button class="btn default">Default</button>

Second step - Add CSS:

To achieve the appearance of 'text button', we removed the default background color and border:

.btn {
  border: none;
  background-color: inherit;
  padding: 14px 28px;
  font-size: 16px;
  cursor: pointer;
  display: inline-block;

/* On mouse-over */
.btn:hover {background: #eee;}
.success {color: green;}
.info {color: dodgerblue;}
.warning {color: orange;}
.danger {color: red;}
.default {color: black;}

Try It Yourself

Text button with separate background

Text button with specific background color on hover:

.btn {
    border: none;
    background-color: inherit;
    padding: 14px 28px;
    font-size: 16px;
    cursor: pointer;
    display: inline-block;

/* 绿色 */
.success {
    color: green;

.success:hover {
    background-color: #04AA6D;
    color: white;

/* 蓝色 */
.info {
    color: dodgerblue;

.info:hover {
    background: #2196F3;
    color: white;

/* 橙色 */
.warning {
    color: orange;

.warning:hover {
    background: #ff9800;
    color: white;

/* 红色 */
.danger {
    color: red;

.danger:hover {
    background: #f44336;
    color: white;

/* 灰色 */
.default {
    color: black;

.default:hover {
    background: #e7e7e7;

Try It Yourself

Related Pages

Tutorial:CSS Button