Can you style a "span" like this, with rounded border?

A style like this is pretty easy in HTML. It’s a span element with a background color, padding, and border, border radius. Is it possible somehow in LibreOffice Writer?

I see in character styles I can add a “highlight color”, which is like the background color, but that’s it.

1 Like

Note that you can do this outside the text flow with drawing objects.

  • A Text Box can have rounded corners but these are barely visible as the radius is related to the line thickness
  • A Shape, in this case Rectangle, Rounded, can be created with area fill and border colour. By double-clicking it you can add text, also use settings to centre the text horizontally and vertically. Radius has to be dragged, I don’t think you can define a corner radius in a dialogue.

I’m almost there. I did as you suggested, and then selected Format > Anchor > As Character to get to flow with the text kind of like an HTML span. But now its not aligned vertically the way I’d like. By selecting Format > Align Text > Top/Center/Bottom, I can change it, but I can’t get it baseline-aligned the way I’d like. Is there a way to do that? Either by specifying baseline alignment, or my manually nudging it vertically by some pixels?

Rob

Having anchored the shape As character, you can select the shape and press Alt+Up-arrow or Alt+Down-arrow to align the drawing shape in small steps.

I have to reiterate that it is out of the text flow; if you copy some text surrounding the object and Edit > Paste Special > Paste as unformatted text you will not paste any words in the shape. If it is in a heading, the text in the shape will not appear in a table of contents.

The text flow issue doesn’t hurt for my current use case, but I could see that being a problem later.

I’m on a Mac and Option+Arrow (up or down) moves it as you described, but unfortunately by more than one pixel.

But this is pretty close to what I want. Thanks!

No. It is not possible yet.

But follow this feature request on the LibreOffice Bugzilla:

That will let users created rounded corners, similar to CSS3’s border-radius.

1 Like

There is presently no rounded corners in border definition.