Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 385145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:27:04+00:00 2026-05-12T15:27:04+00:00

I want to understand what happens when an element whose CSS is display:block is

  • 0

I want to understand what happens when an element whose CSS is display:block is a DOM child of an element whose CSS is display:inline (so that the block element is a child of an inline element).

This scenarios is described in the Anonymous block boxes section for the CSS 2.1 specification: the example includes the following rules …

body { display: inline }
p    { display: block }

… and the accompanying text says …

The BODY element contains a chunk (C1)
of anonymous text followed by a
block-level element followed by
another chunk (C2) of anonymous text.
The resulting boxes would be an
anonymous block box around the BODY,
containing an anonymous block box
around C1, the P block box, and
another anonymous block box around C2.

If you have a display:inline parent element, and if this parent has a child that is display:block, then the existence of that child seems to make the parent nearly behave like display:block, and ignore the fact that it’s defined as display:inline (in that the parent now contains nothing but anonymous and non-anonymous block children, i.e. it no longer contains any inline children)?

My question is, in this scenario (where there’s a display:block child) then what are the differences between the parent’s being defined display:inline instead of display:block?


Edit: I more interested in understanding the CSS 2.1 standard than in how and whether various browser implementations behave in practice.


2nd Edit:

There’s one difference noted in the spec. In the following document, the border for the 2nd ‘block’ paragraph surrounds the whole paragraph and the whole width of the page; whereas the border for the 1st ‘inline paragraph is around each line (even when there are several lines) within the paragraph and no more than the exact width of each line (with each line being shorter than the page width).

<html>
<head>
<style type="text/css">
p.one 
{
border-style:solid;
border-width:1px;
display: inline;
}
p.two 
{
border-style:solid;
border-width:1px;
}
</style>
</head>
<body>
<p class="one">Some text. <b>Note:</b> The "border-width"
property does not work if it is used alone. Use the
"border-style" property to set the borders first.</p>
<p class="two">Some text.</p>
</body>
</html>

If I add the following style rule …

b
{
display: block;
}

… then the “Note:” in the first inline paragraph becomes a block, which splits the paragraph (according to the specs, the first and last part of the paragraph are now in an anonymous block). However, the border around the first and last part of the paragraph are still ‘inline’-style borders: and so, still not the same as if p.one had been declared display:block in the first place.

There’s a quote from the spec, which says,

Properties set on elements that cause
anonymous block boxes to be generated
still apply to the boxes and content
of that element. For example, if a
border had been set on the BODY
element in the above example, the
border would be drawn around C1 (open
at the end of the line) and C2 (open
at the start of the line).

Is the “border-style” property the only type of property where the difference is visible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:27:05+00:00Added an answer on May 12, 2026 at 3:27 pm

    when i read the spec, i find your question actually quite well answered:

    When an inline box contains a block box, the inline box […] [is] broken around the block. The [in]line boxes before the break and after the break are enclosed in anonymous boxes, and the block box becomes a sibling of those anonymous boxes.

    <BODY style="display: inline; ">
    This is anonymous text before the P.
    <P>This is the content of P.</P>
    This is anonymous text after the P.
    </BODY>
    

    The resulting boxes would be an anonymous block box around the BODY, containing an anonymous block box around C1, the P block box, and another anonymous block box around C2.

    or, visually:

    +- anonymous block box around body ---+
    | +- anonymous block box around C1 -+ |
    | |                                 + |
    | +---------------------------------+ |
    |                                     |
    | +- P block box -------------------+ |
    | |                                 + |
    | +---------------------------------+ |
    |                                     |
    | +- anonymous block box around C2 -+ |
    | |                                 + |
    | +---------------------------------+ |
    +-------------------------------------+
    

    now to your question: is this different from <BODY style="display: block; ">?

    yes, it is. while it is still 4 boxes (anonymous block box around body now being BODY block box), the spec tells the difference:

    Properties set on elements that cause anonymous block boxes to be generated still apply to the [generated anonymous block] boxes and content of that element. For example, if a border had been set on the BODY element in the above example, the border would be drawn around C1 (open at the end of the line) and C2 (open at the start of the line):

    +--------------------------------------
    | This is anonymous text before the P. 
    +--------------------------------------
      This is the content of P.
     --------------------------------------+
      This is anonymous text after the P.  |
     --------------------------------------+
    

    this is different to <BODY style="display: block; ">:

    +--------------------------------------+
    | This is anonymous text before the P. |
    |                                      |
    | This is the content of P.            |
    |                                      |
    | This is anonymous text after the P.  |
    +--------------------------------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 195k
  • Answers 195k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Current docs are at link text. However, most for most… May 12, 2026 at 7:02 pm
  • Editorial Team
    Editorial Team added an answer FTS Installed At the Instance Level SELECT SERVERPROPERTY('IsFullTextInstalled') This will… May 12, 2026 at 7:02 pm
  • Editorial Team
    Editorial Team added an answer The Windows Vista/7 gadgets are essentially mini-HTML applications. The user… May 12, 2026 at 7:02 pm

Related Questions

This is similar to What happens when you run a program? , but not
This is pretty much the same problem i have, except with very different code:
I want to write a web app order system using the REST methodology for
I have a bit of code I'm running to test multithreading in MATLAB mex
Over the last few weeks I have been studying the MVC design pattern for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.