Why is one taller than the other?
<button id="playButton" style="display:block;width: 606px;height:50px;border-radius:;background-image: linear-gradient( to right,#000000 199px,#0059dd 199px, #0059dd 202px, #000000 202px, #000000 399px, #0059dd 399px, #0059dd 402px, #000000 402px );border: 3px solid #0059dd; cursor: pointer;font-family: Tahoma; font-weight: bold;font-size:23px; color:#000000;"</button><br>
<br>
<a href="" target="_blank" style="display:block;width: 606px;height:50px;border-radius:;background-image: linear-gradient( to right,#000000 199px,#0059dd 199px, #0059dd 202px, #000000 202px, #000000 399px, #0059dd 399px, #0059dd 402px, #000000 402px );border: 3px solid #0059dd; cursor: pointer;font-family: Tahoma; font-weight: bold;font-size:23px; color:#000000;"></a>
If and only if there was an online version you would be able to use the W3.org CSS Jigsaw validation which would show the CSS syntax error.
What are you talking about, I just want to know why href calculates things differently than button?
This is the full button code.
<button id="playButton" style="display:block;width: 606px;height:50px;border-radius:50px;background-image: linear-gradient( to right,#000000 199px,#0059dd 199px, #0059dd 202px, #000000 202px, #000000 399px, #0059dd 399px, #0059dd 402px, #000000 402px );border: 3px solid #0059dd; cursor: pointer;font-family: Tahoma; font-weight: bold;font-size:23px; color:#000000;"
onclick="
var button = document.getElementById('playButton');
var player = document.getElementById('player'); player.volume=1.0;
if (player.paused) {
playButton.innerHTML = '1980s.fm';
playButton.style.background = 'linear-gradient( to right, #00ffff 199px,#0059dd 199px, #0059dd 202px, #ffffff 202px, #ffffff 399px, #0059dd 399px, #0059dd 402px, #ff00ff 402px )';
player.play();
} else {
playButton.innerHTML = '';
playButton.style.background = 'linear-gradient( to right, #000000 199px,#0059dd 199px, #0059dd 202px, #000000 202px, #000000 399px, #0059dd 399px, #0059dd 402px, #000000 402px )';
player.pause();
}">
</button>
Is button or href more correct than the other when it comes to Width / Height?
The CSS has syntax errors. Browsers will try to guess your requirements.
I believe after the first syntax error the remaining CSS will be ignored.
As mentioned previously and numerous times the CSS should be in a separate style sheet which would simplify validation and drastically reduce your scripting problems.
You didn’t answer my question as to why href is calculating width height differently than button.
What do you not understand about my reply to your question?
Maybe someone else will have a better answer for me.
asasass:
<button id=“playButton” style=“display:block;width: 606px;height:50px;border-radius:;background-image: linear-gradient( to right,#000000 199px,#0059dd 199px, #0059dd 202px, #000000 202px, #000000 399px, #0059dd 399px, #0059dd 402px, #000000 402px );border: 3px solid #0059dd ; cursor: pointer;font-family: Tahoma; font-weight: bold;font-size:23px; color:#000000 ;”</button>
The original post has CSS syntax errors and is different to your validated script. I am confused as to why you validated the different script.
W3C CSS Validator results for TextArea (CSS level 3)
Sorry! We found the following errors (1)
URI : TextArea
0 Parse Error Lexical error at line 1, column 363. Encountered: “<” (60), after : “<button id="playButton" style="display:block;width: 606px;height:50px;border-radius:;background-image: linear-gradient( to right,#000000 199px,#0059dd 199px, #0059dd 202px, #000000 202px, #000000 399px, #0059dd 399px, #0059dd 402px, #000000 402px );border: 3px solid #0059dd ; cursor: pointer;font-family: Tahoma; font-weight: bold;font-size:23px; color:#000000 ;"”
asasass
February 2, 2017, 7:37am
12
I was only asking about the width and height, I wasn’t asking about the whole entire code.
ronpat
February 2, 2017, 7:37am
13
While there are a couple of errors in your code, there is nothing wrong with your code that would cause that problem.
A button has a border by default. It is considered part of the dimensions of the button.
An anchor is an inline object by default and has no border. You have added a border to the button and the anchor. The button sees the border as part of its dimensions. The anchor sees the button as an additional width and height.
You know about the box model.
To make the anchor and the button have matching dimensions, one must apply {box-sizing: border-box} to the anchor.
asasass
February 2, 2017, 7:37am
14
I just wanted to know why button calculates width & height differently than href.
asasass
February 2, 2017, 7:38am
15
What are the errors that you see?
asasass
February 2, 2017, 7:41am
16
ronpat:
box-sizing: border-box
Will that work?
style="box-sizing: border-box;
asasass
February 2, 2017, 7:49am
18
A button has a border by default.
Is there a way to visibly see the border, or is it entirely invisible?
ronpat
February 2, 2017, 7:52am
19
Type
<button></button>
on an HTML page and open it in your browser.
It will be very small, but it’s there.
asasass
February 2, 2017, 7:55am
21
border: none ; removes it.
1 Like