• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Change Button Color in HTML

February 16, 2024 by admin Category: How To

You are viewing the article How to Change Button Color in HTML  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

X

This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

This article has been viewed 16,949 times.

This article will show you how to change button color in HTML. You can change the button color using plain HTML (plain HTML) or CSS (cascade stylesheets) in HTML5.

Table of Contents

  • Steps
    • Using HTML
    • Using CSS

Steps

Using HTML

Image titled 11147764 1

Image titled 11147764 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/cd/11147764-1.jpg/v4-728px-11147764-1.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/c/cd/11147764-1.jpg/v4-728px-11147764-1.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,” bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Type <button in the HTML body. This is the beginning of the button tag of the HTML line of code. The body of the HTML is the paragraph between the <body> and </body> tags. The body is where the visible elements of the web page are placed in HTML.
Image titled 11147764 2

Image titled 11147764 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/fe/11147764-2.jpg/v4-728px-11147764-2.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/f/fe/11147764-2.jpg/v4-728px-11147764-2.jpg”,”smallWidth”:460,”smallHeight”:343,”bigWidth”:728,” bigHeight”:543,”licensing”:”<div class=”mw-parser-output”></div>”}
Type style= after “button” in your button tag. This is the step to declare style elements to the button tag. All style elements will be placed after the “=”.
Image titled 11147764 3

Image titled 11147764 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/8b/11147764-3.jpg/v4-728px-11147764-3.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/8/8b/11147764-3.jpg/v4-728px-11147764-3.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,” bigHeight”:550,”licensing”:”<div class=”mw-parser-output”></div>”}
Add double quotes (“) after the equal sign (=). All style elements in your HTML button tag should be enclosed in double quotes.
Image titled 11147764 4

Image titled 11147764 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/8f/11147764-4.jpg/v4-728px-11147764-4.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/8/8f/11147764-4.jpg/v4-728px-11147764-4.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,” bigHeight”:547,”licensing”:”<div class=”mw-parser-output”></div>”}
Type background-cpor: inside quotes after “style=”. This element is used to change the background color of the button.
Image titled 11147764 5

Image titled 11147764 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/c5/11147764-5.jpg/v4-728px-11147764-5.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/c/c5/11147764-5.jpg/v4-728px-11147764-5.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,” bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the color name or hexadecimal code after “background-cpor:”. You can type the name of the color (such as blue) or the hexadecimal color.

  • If you want to search for hexadecimal (Hex) codes, go to https://www.google.com/search?q=cpor+picker using a web browser. Use the slider at the bottom to choose a color. Use the circle in the window to choose the shade of the color. Highlight and copy (copy) the 6-digit code (including the pound sign) in the left sidebar and paste it into your button tag.
  • You can also type “transparent” as the transparent background color. [1] X Research Source
Image titled 11147764 6

Image titled 11147764 6

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/52/11147764-6.jpg/v4-728px-11147764-6.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/5/52/11147764-6.jpg/v4-728px-11147764-6.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type a semicolon (;) after the word background cpor. Use semicolons to separate different style elements in the HTML button tag.
Image titled 11147764 7

READ More:   How to Give a Speech Without Preparedness

Image titled 11147764 7

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a4/11147764-7.jpg/v4-728px-11147764-7.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/a/a4/11147764-7.jpg/v4-728px-11147764-7.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,” bigHeight”:549,”licensing”:”<div class=”mw-parser-output”></div>”}
Type border-cpor: in quotes after “style=”. This element is used to colorize the border around the button. You can enclose style elements in any sequence within double quotes after “style=”. Each element must be separated by a semicolon (;).
Image titled 11147764 8

Image titled 11147764 8

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/83/11147764-8.jpg/v4-728px-11147764-8.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/8/83/11147764-8.jpg/v4-728px-11147764-8.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,” bigHeight”:551,”licensing”:”<div class=”mw-parser-output”></div>”}
Type a color name or hexadecimal code for the border color. The color name or hexadecimal code for the border will be after the “border-cpor:” element.

  • If you want to remove the border, type border:none instead of the “border-cpor:” element.
Image titled 11147764 9

Image titled 11147764 9

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/5b/11147764-9.jpg/v4-728px-11147764-9.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/5/5b/11147764-9.jpg/v4-728px-11147764-9.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type a semicolon (;) after border cpor. Use semicolons to separate different style elements in the HTML button tag.
Image titled 11147764 10

Image titled 11147764 10

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d4/11147764-10.jpg/v4-728px-11147764-10.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/d/d4/11147764-10.jpg/v4-728px-11147764-10.jpg”,”smallWidth”:460,”smallHeight”:343,”bigWidth”:728,” bigHeight”:543,”licensing”:”<div class=”mw-parser-output”></div>”}
Type cpor: inside quotes after “style=”. This element is used to change the button’s text color. You can enclose style elements in any sequence within double quotes after “style=”. Each element must be separated by a semicolon (;).
Image titled 11147764 11

Image titled 11147764 11

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/53/11147764-11.jpg/v4-728px-11147764-11.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/5/53/11147764-11.jpg/v4-728px-11147764-11.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,” bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the name of the color or the hexadecimal code. Type it after “cpor:” in the style element. This is the step to change the color of the text in the button.
Image titled 11147764 12

Image titled 11147764 12

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/97/11147764-12.jpg/v4-728px-11147764-12.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/9/97/11147764-12.jpg/v4-728px-11147764-12.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,” bigHeight”:550,”licensing”:”<div class=”mw-parser-output”></div>”}
Type double quotes (“) after all style elements.All your style elements should be enclosed in double quotes after “style=” in the button tag. When you are done adding all the sections. your style element, type double quotes (“) at the end to close the style element.
Image titled 11147764 13

Image titled 11147764 13

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/7/79/11147764-13.jpg/v4-728px-11147764-13.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/7/79/11147764-13.jpg/v4-728px-11147764-13.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,” bigHeight”:545,”licensing”:”<div class=”mw-parser-output”></div>”}
Type > after the style element. This is the step to close the button opening tag.
Image titled 11147764 14

Image titled 11147764 14

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/46/11147764-14.jpg/v4-728px-11147764-14.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/4/46/11147764-14.jpg/v4-728px-11147764-14.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,” bigHeight”:549,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the text of the button after the button tag. After you’ve created the button opening tag, type the text you want to write in the button behind the tag.
Image titled 11147764 15

Image titled 11147764 15

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/ad/11147764-15.jpg/v4-728px-11147764-15.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/a/ad/11147764-15.jpg/v4-728px-11147764-15.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,” bigHeight”:545,”licensing”:”<div class=”mw-parser-output”></div>”}
Type </button> after the button text. This is the button’s closing tag. Your button has been created. Your HTML code should look like this.

 <!DOCTYPE html> < html > < body > < button style = "background-cpor:red; border-cpor:blue; cpor:white" > Button Text </ button > </ body > </ html > 

Using CSS

Image titled 11147764 16

Image titled 11147764 16

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/21/11147764-16.jpg/v4-728px-11147764-16.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/2/21/11147764-16.jpg/v4-728px-11147764-16.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type <head> at the top of your HTML text. This is the step that creates the header for your HTML text. The head of the text is where the information is not displayed on your site. This section includes the page’s metadata, title, and style files.
Image titled 11147764 17

READ More:   How to Describe Human Appearance

Image titled 11147764 17

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/ac/11147764-17.jpg/v4-728px-11147764-17.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/a/ac/11147764-17.jpg/v4-728px-11147764-17.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type <style> . This tag helps to add a place on your site for cascading stylesheet (CSS) files. This section is at the top of your HTML text.

  • Some HTML documents use external stylesheets. In this case, you will need to find the location of the external CSS file and edit the button style file on that text.
Image titled 11147764 18

Image titled 11147764 18

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/80/11147764-18.jpg/v4-728px-11147764-18.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/8/80/11147764-18.jpg/v4-728px-11147764-18.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,” bigHeight”:549,”licensing”:”<div class=”mw-parser-output”></div>”}
Type .button { in a separate line after the style section. This is the step that opens the stylesheet for the button you are styling. [2] X Research Source

  • You can also make the button change color when you hover the mouse pointer over the button by creating your own stylesheet with the opening tag .button:hover { .
Image titled 11147764 19

Image titled 11147764 19

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/dd/11147764-19.jpg/v4-728px-11147764-19.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/d/dd/11147764-19.jpg/v4-728px-11147764-19.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,” bigHeight”:547,”licensing”:”<div class=”mw-parser-output”></div>”}
Type background-cpor: . This is a separate line in the node stylesheet file. This element helps to change the background color of the button.
Image titled 11147764 20

Image titled 11147764 20

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d8/11147764-20.jpg/v4-728px-11147764-20.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/d/d8/11147764-20.jpg/v4-728px-11147764-20.jpg”,”smallWidth”:460,”smallHeight”:343,”bigWidth”:728,” bigHeight”:543,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the name of the color or hexadecimal code and then type a semicolon (;). Type it after the “background-cpor:” element in the button stylesheet. This is the step to change the background color of the button.

  • If you want to search for hexadecimal (Hex) codes, go to https://www.google.com/search?q=cpor+picker using a web browser. Use the slider at the bottom to choose a color. Use the circle in the window to choose the shade of the color. Highlight and copy the 6-digit code (including the pound sign) in the left sidebar.
  • You can also type “transparent” as the background color to make the background transparent.
Image titled 11147764 21

Image titled 11147764 21

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/1d/11147764-21.jpg/v4-728px-11147764-21.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/1/1d/11147764-21.jpg/v4-728px-11147764-21.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,” bigHeight”:547,”licensing”:”<div class=”mw-parser-output”></div>”}
Type border-cpor: . This element changes the color of the border around the button. Type it in a separate line in the node stylesheet file.
Image titled 11147764 22

Image titled 11147764 22

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/ac/11147764-22.jpg/v4-728px-11147764-22.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/a/ac/11147764-22.jpg/v4-728px-11147764-22.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,” bigHeight”:550,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the name of the color or hexadecimal code and then type a semicolon (;). This is the step to change the color of the border around the button. Type it after the “border-cpor:” element in the button stylesheet.

  • If you want to remove the border, type border:none; in place of the “border-cpor:colorname” element.
Image titled 11147764 23

Image titled 11147764 23

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a1/11147764-23.jpg/v4-728px-11147764-23.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/a/a1/11147764-23.jpg/v4-728px-11147764-23.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,” bigHeight”:547,”licensing”:”<div class=”mw-parser-output”></div>”}
Type cpor: . Type it in a separate line in the stylesheet. This element helps to change the color of the text in the button.
Image titled 11147764 24

READ More:   Dreaming of snakes: meaning, interpretation and other information

Image titled 11147764 24

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/53/11147764-24.jpg/v4-728px-11147764-24.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/5/53/11147764-24.jpg/v4-728px-11147764-24.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Type the name of the color or hexadecimal code and then type a semicolon (;). This is the step to change the color of the text inside the button. Type it after the “cpor:” element in the node stylesheet.
Image titled 11147764 25

Image titled 11147764 25

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/0/09/11147764-25.jpg/v4-728px-11147764-25.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/0/09/11147764-25.jpg/v4-728px-11147764-25.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,” bigHeight”:549,”licensing”:”<div class=”mw-parser-output”></div>”}
Type } on a separate line. This is the step to close your button stylesheet file. You can create multiple button style files, as long as you give each button a different name.
Image titled 11147764 26

Image titled 11147764 26

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/f7/11147764-26.jpg/v4-728px-11147764-26.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/f/f7/11147764-26.jpg/v4-728px-11147764-26.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,” bigHeight”:548,”licensing”:”<div class=”mw-parser-output”></div>”}
Type </style> after you are done with your CSS. After you’ve created all of your style files, type “</style>” on a separate line to close your HTML text styling.
Image titled 11147764 27

Image titled 11147764 27

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/29/11147764-27.jpg/v4-728px-11147764-27.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/2/29/11147764-27.jpg/v4-728px-11147764-27.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,” bigHeight”:547,”licensing”:”<div class=”mw-parser-output”></div>”}
Type </head> . This is the step that closes the beginning of the HTML text.
  • Image titled 11147764 28

    Image titled 11147764 28

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/8b/11147764-28.jpg/v4-728px-11147764-28.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/8/8b/11147764-28.jpg/v4-728px-11147764-28.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,” bigHeight”:544,”licensing”:”<div class=”mw-parser-output”></div>”}
    Type <a href="url" class="button">Button text</a> in the body of your HTML text. This is the step to add the button to the visible part of the HTML using the style file in the Style section of the HTML document. Please replace “url” with the web address the button is linked to. The body of your HTML text is the paragraph between the <body> and </body> tags of your HTML text. Your HTML code will look like this:

     <!DOCTYPE html> < html > < head > < style > . button { background-cpor : blue ; border-cpor : red ; cpor : white ; } </style> < / head > <body> <a href="https://www.wikihow.com" class="button" > Home < / a > </body> < / html > _ _ _ _ _ _ _ _ _ _ 
  • X

    This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

    The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

    This article has been viewed 16,949 times.

    This article will show you how to change button color in HTML. You can change the button color using plain HTML (plain HTML) or CSS (cascade stylesheets) in HTML5.

    Thank you for reading this post How to Change Button Color in HTML at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « How to Make Your Boyfriend Crazy For You
    Next Post: How to Change Computer Date and Time Through Command Prompt »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge