Jump to content

Spans seem to be Blocking, even with inline block set


simona6

Recommended Posts

I've to a strange problem with some basic HTML and CSS.

I know you can put a <span> inside a <div> and it will show inline, such as using additional classes on inline text.  For some reason, ours seems to 'block' to the next line.

.grve-title > span {
    display: inline-block;
    white-space: nowrap;
}

With this set, our Spans are going to the next line, but only if the span is long.  So if you have a span that is longer than the container, it will wrap.  If it is one word, it won't.

Any ideas??  If I deselect the display part of this class in Inspection, it doesn't block at all, it just goes to default.

I don't however know how to disable this "display: inline-block"?!  

Link to comment
Share on other sites

If it has the undesired behavior with inline-block and the desired behavior without inline-block then it sounds like you've found the source of your problem.

11 hours ago, simona6 said:

I don't however know how to disable this "display: inline-block"?!  

By editing the CSS?

If it's there now then that probably means something needs to use it. If so then you need to do something special for your span, but without knowing more about... well, everything, it would be really hard to give any sort of specific advice. Perhaps you shouldn't be using a span at all?

Link to comment
Share on other sites

A span's default display value in a browser is inline, so unless there's a reason to change it it should do what you want natively. As requinix pointed out, if it's there it may be used - try adding a helper class and overriding the display to 'inline' on that class.

Link to comment
Share on other sites

Literally the reason for the existence of a span, is that it's display: inline.  This respects the style of the parent element.  When you set it to inline-block, you are causing it to have "block-like" properties, where it will have margins and padding that effect the box model.  You should ask the question as to why the spans you are using have this class applied, and why someone set the style to be inline-block.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.