2

This shows that "display" is initially "inline" for all elements: https://www.w3.org/TR/css-display-3/#the-display-properties

However, this says "(and assuming the DIV and the P both have 'display: block')": https://www.w3.org/TR/CSS2/visuren.html#block-level

I did see this question that shows that the browser sets the default display value. Difference between HTML block elements and CSS display block property.

Q. How does this reconcile with the CSS Spec. statement that "display" is initially "inline" for all elements? Does the CSS specification statement about "initially inline" refer to the state before the browser sets display:block for block-level elements?

1
  • Specification != implementation Commented Jan 18, 2023 at 7:20

1 Answer 1

1

Does the CSS specification statement about "initially inline" refer to the state before the browser sets display:block for block-level elements?

It refers to the default value of a property if nothing is defined including any browser default style.

Each property has an initial value, defined in the property’s definition table. If the property is not an inherited property, and the cascade does not result in a value, then the specified value of the property is its initial value. ref

The fact that you can read "(and assuming the DIV and the P both have 'display: block')" confirms the logic because the Specification is not telling you that p and div should be or are block elements but let's assume they are block element for the sake of the explanation that comes next.

div and p are flow content (WhatWG) and thus presumably have "display: block" by default.

"Flow content" and "display: block" are not linked together. Some elements are flow content but they don't have "display: block" like a, span and many others.

The content models has nothing to do with the display value.

Sign up to request clarification or add additional context in comments.

2 Comments

@Coder this is how browser define them by default since too long. It was for sure discussed somewhere and defined to be like that but still it has nothing to do with the "initial" value and it's not contradictory with the Specification. You can start your searching here: w3.org/TR/CSS22/cascade.html#cascade .. the "User Agent" is what you are looking for. You will probably find the source of such implementation.
Regarding your statement that flow content is not linked to display:block, this shows that phrasing content is generally inline: stackoverflow.com/questions/30233447/… That was basically what I meant by flow content (non-phrasing) generally being block-level, however I didn't know enough to exactly convey that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.