Skip to content
Sign upLog in
← Back to Community

how to add button in html ?

Profile icon
RamBarabdeCoder

plz tell how to add it and then plz give codes and also any new thing you about buttons like color changing and many things in html language.

Voters
Profile icon
RamBarabdeCoder
Comments
hotnewtop
Profile icon
[deleted]

I can help you! The way to create a button is like this:

<button href="(location where u want the user to go after clicking on it)">Name of the button</button>

To change the color, you can do:

<button id="button-red">This is a button that is red</button>

and in the CSS file u do:

#button-red { background-color: red; }

and boom ur done

Profile icon
[deleted]

If my comment answered the question then select the green check mark next to it, thanks!

Profile icon
RamBarabdeCoder

@Aphmeta
Thank You

Profile icon
InvisibleOne

np

@RamBarabdeCoder

Profile icon
Nuker13764

Doesn't work. Copied and pasted!

Profile icon
RamBarabdeCoder

Thank you all

@Aphmeta
,@InvisibleOne,@ruiwenge2 and more

Profile icon
InvisibleOne

In the HTML file

<button onclick="alert('You clicked me!');">Click Me!</button>

then in the css

button { padding: 15px; font-size: 10px; color: white; font-family: 'Trebuchet MS'; background-color: darkgrey; border-radius: 5px; border: 6px solid black; }

Something like that

Profile icon
RamBarabdeCoder

@InvisibleOne
thanks

Profile icon
RamBarabdeCoder

Can Any one tell me that when the cursor will goto the button then how it will change color

Profile icon
ruiwenge2

@RamBarabdeCoder
in css:

button:hover { background: blue; }
Profile icon
ruiwenge2
<button>Text</button>
Profile icon
[deleted]

@ruiwenge2
u forgot about href and he also asked for color code

Profile icon
[deleted]

@ruiwenge2
and u need to specify the language as html when u put code markdown like

<button href="https://www.youtube.com">YouTube</button>
Profile icon
RamBarabdeCoder

@Aphmeta
Thank you

Profile icon
RamBarabdeCoder

@ruiwenge2
Thank you