Is there a way to make an inline element more clickable without affecting other elements? Adding padding helps, but it can disrupt the layout. I tried using negative margin to counteract the padding, but it produced some unexpected results:
span {
padding: 5px;
margin: -5px;
background-color: red;
cursor: pointer;
}
ab<span>c</span>def
When trying to hover over the element, the click area does not cover the entire red section and seems to shift towards the right of the letter c
. This issue also affects the onClick event handler. What causes this behavior, and is there a way to fix it?