Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missed an IE mention / centering using margin #34174

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions files/en-us/web/css/margin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ The top and bottom margins have no effect on _non-[replaced](/en-US/docs/Web/CSS

### Horizontal centering

To center something horizontally in modern browsers, you can use {{cssxref("display")}}`: flex;` {{cssxref("justify-content")}}`: center;`.
You can horizontally center an element within its parent by setting `margin: 0 auto;`.

However, in older browsers like IE8-9 that do not support Flexible Box Layout, these are not available. In order to center an element inside its parent, use `margin: 0 auto;`.
More commonly, though, people horizontally center element by setting {{cssxref("display")}}`: flex;` {{cssxref("justify-content")}}`: center;` on a container, which [centers its flex item](/en-US/docs/Web/CSS/CSS_flexible_box_layout/Aligning_items_in_a_flex_container) children.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • How about the phrasing below (we can drop "to center an element horizontally" to avoid it repetition from the previous para)
  • The quotes after the cssxref are adding an extra space before the ":". We can either remove the cssxref or link the entire property value pair.
Suggested change
More commonly, though, people horizontally center element by setting {{cssxref("display")}}`: flex;` {{cssxref("justify-content")}}`: center;` on a container, which [centers its flex item](/en-US/docs/Web/CSS/CSS_flexible_box_layout/Aligning_items_in_a_flex_container) children.
A more common method to center an element horizontally is by setting `display: flex;` and `justify-content: center;` on a container, which [centers its flex item](/en-US/docs/Web/CSS/CSS_flexible_box_layout/Aligning_items_in_a_flex_container) children.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used your suggestion, and linked justify-content

estelle marked this conversation as resolved.
Show resolved Hide resolved

### Margin collapsing

Expand Down