Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button text to wrap like inline spans

Tags:

css

Is it possible to wrap button text next to a span? So that the button appears over multiple lines.

E.g:

div {
  background-color: #ccc;
  padding: 10px;
  width: 150px;
}

button {
  border: 0;
  background: transparent;
}
<div>
  <span>Lorem ipsum dolor sit amet </span><button>Button with a long label</button>
</div>

In the case above the button text should continue as though it were part of the text, similar to a link.

like image 811
user1486133 Avatar asked Aug 11 '26 13:08

user1486133


1 Answers

display:contents; can do this but you may lose more than what you will win (it can break the accessibility as well)

div {
  background-color: #ccc;
  padding: 10px;
  width: 150px;
}

button {
  border: 0;
  background: transparent;
  display:contents;
}
<div>
  <span>Lorem ipsum dolor sit amet </span><button><span>Button with a long label</span></button>
</div>
like image 108
Temani Afif Avatar answered Aug 14 '26 10:08

Temani Afif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!