Skip to content
Sign upLog in
← Back to Community

how to add images to your button in CSS?

Profile icon
potatojs

hi i want to know how to add images to your html button element using CSS?

Answered by zplusfour [earned 5 cycles]
View Answer
Voters
Profile icon
MatheusRogerio
Profile icon
zplusfour
Profile icon
potatojs
Comments
hotnewtop
Profile icon
zplusfour

u can
Just make for an image a onclick option

Profile icon
potatojs

sorry i didn't [email protected]

Profile icon
zplusfour

@potatojs

HTML:

<script> function click(){ alert('CLICKED!') } </script> <img src="image.png" onclick="click()">

Oh srry u order CSS
no css is 'carcading style sheets' it is not functional
So you can do it only with JS

Profile icon
potatojs

ok :(
that 's [email protected]

Profile icon
zplusfour

@potatojs
thank you for the 5 cycles :D

Profile icon
zplusfour

@potatojs
CSS isn't a functional language
so u shouldn't be sad :D

Profile icon
Coder100

Sorry, you can't do that. Use JS.
However, there is a :before and :after tag that can append text:

div::before { content: "This is text only."; } div::after { content: "This is text only."; }
Profile icon
potatojs