Consider the snippet below:
div {
width: 150px;
line-height: 1.5;
}
a,
button {
background: red;
}
button {
display: inline;
font-size: inherit;
font-family: inherit;
padding: 0;
margin: 0;
border: none;
text-align: left;
}
<div>
Some text
<a>
<span>abcdefghi abcdefghi abcdefghi abcdefghi</span>
</a>
Some text
<br />
<br /> Some text
<button>
<span>abcdefghi abcdefghi abcdefghi abcdefghi</span>
</button> Some text
</div>
How can I make sure that the appearance of the second block containing <button>
as a wrapper matches the one with <a>
as a wrapper?
I'm attempting to create an in-text button for opening a modal, and the issue arises when the text wraps to a new line. While I could use <a>
, it wouldn't be semantically correct.
Using white-space: nowrap
is not a viable solution.
I assumed that setting display: inline
would resolve the problem, but could there be any default browser styles affecting this behavior?
This solution needs to be compatible with IE10, meaning I cannot utilize display: content
or unset: all
.