I believe this to be a problem.

Take the following search-box example:

<div class="container-inline">
  <div class="form-item form-type-textfield form-item-search-block-form">
    <label for="edit-search-block-form--2" class="element-invisible">Search </label>
    <input type="text" class="form-text" maxlength="128" size="15" value="" name="search_block_form" id="edit-search-block-form--2" title="Enter the terms you wish to search for.">
  </div>
  <div id="edit-actions" class="form-actions form-wrapper">
    <input type="submit" class="form-submit" value="Search" name="op" id="edit-submit">
  </div>
  <input type="hidden" value="form-V2dWadKs3DZD50-WgvEgQKgWEkRS_zfttOOsZeqbcEU" name="form_build_id">
  <input type="hidden" value="RozGGJ4Pg_kzwKdSXEdIMng-SOjgi1otZmk9oIW6s7I" name="form_token">
  <input type="hidden" value="search_block_form" name="form_id">
</div>

The problem is that the divs and inputs nested inside the immediate children of the .container-inline will also lose all of their block structure. In particular I have seen browsers, such as Opera, collapse the entire search box and input button into nothing. (this can happen if the button is rethemed to show an image and no text).

The system.base.css has the following relevant lines:

.container-inline div,
.container-inline label {
  display: inline;
}

I am suggesting to change it to the following:

.container-inline > div,
.container-inline > label {
  display: inline;
}

This should have the same affect, but only work on immediate child elements instead of all nested elements.

Reference: http://www.w3.org/TR/2011/REC-CSS2-20110607/selector.html#child-selectors

Comments

TransitionKojo’s picture

Version: 7.x-dev » 8.x-dev
Component: theme system » CSS
Issue tags: +Needs backport to D7
TransitionKojo’s picture

This issue relates to an IE6 compatibility problem (IE6 lacking support for Child selectors). Although it's being committed to 8.x-dev, there is currently an issue in the queue to drop IE6 support from 8.x. (see http://drupal.org/node/308865).

It can be committed to 8.x-dev once IE6 support has been dropped in http://drupal.org/node/308865. For Drupal 7 it will need to have a different solution that retains IE6 support (i.e. not using the child selector). [Catch TOTALLY helped me with that last sentence.]

jacine’s picture

Status: Needs review » Postponed (maintainer needs more info)

The problem is that the divs and inputs nested inside the immediate children of the .container-inline will also lose all of their block structure.

But... that's kinda what it's supposed to do. It isn't designed to deal with nested block elements. If you're theming a submit to use an background image, then declaring inline-block or block as the display is standard practice. It's also fairly simple to remove the .container-inline class if it's not serving your needs. Using the child selector would make the instances where you need to override its contents require more specific selectors. So, we should really avoid that unless it's necessary.

have seen browsers, such as Opera, collapse the entire search box and input button into nothing. (this can happen if the button is rethemed to show an image and no text).

I've never seen or heard of this happening before. Can you provide a test case in JS Bin or jsFiddle that demonstrates this?

jacine’s picture

Issue tags: +Front end

Tagging

sun’s picture

Status: Postponed (maintainer needs more info) » Active
Issue tags: -Needs backport to D7

Let's discuss this some more. I'd love to see brainstorming and experiments on the idea.

It makes sense to some extent, but direct children are not sufficient. If we can make this work in an intelligent and smart way, I'd be in favor.

Regarding experiments, those will need (plenty of) sample markup (also forms) somewhere. This could either happen in a testing module in core, or as a dedicated test case in http://drupal.org/project/design

Lastly, a backport is definitely not possible.

dobe’s picture

What if we just used "inline-block" instead of "inline" for this?

.container-inline div, 
.container-inline label {
  display: inline-block;
}

Ran into this issue using the chosen module and "Seven" administration theme.

thekevinday’s picture

One of the things I have more recently got into a habit of doing is adding class names that tag my div as different from some other div.

The downside of this is there is a bit more noise in the HTML by having even more class names.

For example, I wanted a way to have a site dynamically change from HTML < 5 to HTML 5 with as little code changes as possible. So, when I generated by HTML5 tag, such as aside, I appended a class name of html_tag-aside. Then, I did some browser identification during the theme preprocess and decided whether or not to produce an HTML5 or non-HTML5 tag.

Now, doing this allows me to have the same CSS code without having to update anything or having extra many lines (which means it provides better CSS performance).

This concept can then be used for the case of nested tags.

.container-inline .container-inline-div,
.container-inline .container-inline-label {
  display: inline-block;
}

Another problem with this is that this should require creating a new coding style that must be followed for consistency.

yesct’s picture

Issue tags: -Front end +frontend

correcting the tag to the more common one.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

bhumikavarshney’s picture

Status: Active » Needs review

As child-element css not supported by IE. So to have the same effect on the immediate div and label, we need to use identical classes.
The above code also contains identical classes so by using theme we can achieve the same layout in all the browsers.
We can try this to avoid cross browser issues:

.container-inline .form-item,
.container-inline label {
display: inline;
}
For label as of now in the above code only single label is there to apply on the css only on single label we need to give identical class.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

tinto’s picture

Status: Needs review » Closed (works as designed)
Issue tags: +Bug Smash Initiative

This issue was has been reviewed and discussed as 'triage issue of the day' as part of the Bug Smash Initiative.

The consensus is that the solution(s) proposed in this thread could potentially break/change a lot of existing site UIs, so cure may at this point be worse than the illness. I would argue that this does not qualify as a bug, but as a design flaw.

For this reason, I am marking this issue as Closed (works as designed). (Although admittedly, the design could have been better.) If anyone disagrees, please feel free to reopen this issue and post your motivation for doing so in the comments.

Thank you!