Code Monkey home page Code Monkey logo

Comments (16)

w0rm avatar w0rm commented on July 28, 2024

I've been using both paddings and margins on inline elements. Left and right margins are sometimes needed to add additional spaces to inline elements, and I used padding to control vertical position of bottom border (for custom underlines).

from csslint.

riddle avatar riddle commented on July 28, 2024

Margin on inline elements won’t work (it will on inline-block though). The only exception is IE6 and 7.

from csslint.

stubbornella avatar stubbornella commented on July 28, 2024

I think IE6/7 treat inline like inline block and do show margins, but maybe I'm wrong. Seems like we need a test case.

from csslint.

thierryk avatar thierryk commented on July 28, 2024

afaik, left and right margins on inline elements work

from csslint.

w0rm avatar w0rm commented on July 28, 2024

Here is a test case: http://jsfiddle.net/6Vqnc/

from csslint.

riddle avatar riddle commented on July 28, 2024

I think IE6/7 treat inline like inline block and do show margins, but maybe I'm wrong.

They do. Still, I don’t understand why padding is included in that warning. :)

from csslint.

thierryk avatar thierryk commented on July 28, 2024

IE6 and 7 treat inline elements like other browsers do, and like other browsers left and right padding/margin 'work' (they create space). Afaik, IE6 and 7 will treat an inline box as an inline-block only if the former has a layout.

span {
    margin:30px;
    padding:30px;
}

em {
    margin:30px;
    padding:30px;
    zoom:1;
}

The span should look the same across browsers, but not the em. The latter will change the flow because of top/bottom margin and padding that will behave as on block elements.

from csslint.

w0rm avatar w0rm commented on July 28, 2024

Top and bottom paddings on inline elements are consistent among all browsers. They just don't behave like on block elements (vertical paddings expand background of inline element, but don't change vertical alignment of the text).
I'm surprised how can it be something new to know.

from csslint.

thierryk avatar thierryk commented on July 28, 2024

Actually, I noticed this is something confusing for many authors. I have this page that shows a few test-cases explaining what's normal/expected behavior:

http://www.css-101.org/inline-level-elements/

[/shameless plug]

from csslint.

riddle avatar riddle commented on July 28, 2024

An element with display set inline-block accepts margin, inline doesn’t. I’m not sure what is the problem here, the behavior is pretty simple.

from csslint.

w0rm avatar w0rm commented on July 28, 2024

Inline elements do accept left and right margins, period, enough said.

from csslint.

nzakas avatar nzakas commented on July 28, 2024

So it sounds like the suggestion here is that display: inline elements used with left/right padding or margin should not cause a warning BUT if top/bottom are used, that should still be a warning. Is that correct? Nicole?

from csslint.

thierryk avatar thierryk commented on July 28, 2024

I'd say yes for top/bottom margins, but for padding it's different. top/bottom padding play a role in the painting of background and borders, so it's perfectly normal to include them if it is to serve that purpose.
A common use for example, is to apply a bottom padding on the active "tab" in a menu to hide part of the bottom border that styles the list. If this works nicely, it is because of the special way padding works on inline elements.

from csslint.

riddle avatar riddle commented on July 28, 2024

I agree wholeheartedly with thierryk. The whole reason to submit the issue was to exclude the warning for padding applied on inline elements. It doesn’t make sense.

from csslint.

drobati avatar drobati commented on July 28, 2024

This confused me yesterday enough to come find this issue today.

Chrome was displaying my list item elements (for my menu) with padding (left and right) and display inline fine. Glad to see that this should just apply to margin which I hadn't used.

from csslint.

nzakas avatar nzakas commented on July 28, 2024

Okay, so list of changes to be made here:

  1. display: inline with any padding is okay.
  2. display: inline with margin-right or margin-left is okay.

from csslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.