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

margin-left don't applies to ::first-line #31806

Closed
Akindin opened this issue Jan 19, 2024 · 7 comments · Fixed by mdn/data#706
Closed

margin-left don't applies to ::first-line #31806

Akindin opened this issue Jan 19, 2024 · 7 comments · Fixed by mdn/data#706

Comments

@Akindin
Copy link
Contributor

Akindin commented Jan 19, 2024

MDN URL

https://developer.mozilla.org/en-US/docs/Web/CSS/margin-left

What specific section or headline is this issue about?

Formal Definition applies to

What information was incorrect, unhelpful, or incomplete?

margin-left doesn't work on ::first-line pseudoelement

What did you expect to see?

first line of text to have indentation

Do you have any supporting links, references, or citations?

https://codepen.io/Akindin/pen/MWxmqVg

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@Akindin Akindin added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 19, 2024
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs and removed Content:CSS Cascading Style Sheets docs labels Jan 19, 2024
@Akindin
Copy link
Contributor Author

Akindin commented Jan 19, 2024

Same with margin-right

@MohammedAslam106
Copy link

The following properties apply to the ::first-line pseudo-element:

font properties
color properties
background properties
word-spacing
letter-spacing
text-decoration
vertical-align
text-transform
line-height
clear

We need to change the applies to section.

Source: https://www.w3schools.com/css/css_pseudo_elements.asp

@ferdnyc
Copy link
Contributor

ferdnyc commented Jan 20, 2024

Indeed; the behavior can be confusing, too, because margin properties do apply to ::first-letter (as the documentation claims), just not ::first-line.

The content of Formal Definition sections is auto-generated from data in the mdn/data repo, specifically (in this case) https://github.com/mdn/data/blob/main/css/properties.json which does (incorrectly) claim, for margin-left:

   "alsoAppliesTo": [ 
     "::first-letter", 
     "::first-line" 
   ], 

That should just be:

   "alsoAppliesTo": [ 
     "::first-letter"
   ],

I'll correct the margin-{left,right,top,bottom} definitions in that data, check for any other properties that claim ::first-line support when they shouldn't, and open a PR in mdn/data to get that fixed. Thanks, @Akindin !

@wbamberg
Copy link
Collaborator

I wonder why though, the spec for :first-line says:

The following CSS properties apply to a ::first-line pseudo-element:
...
any other properties defined to apply to ::first-line by their respective specifications

...and the spec for margin says:

All properties in this module apply to the ::first-line and ::first-letter pseudo-elements.

So is this nonstandard? (though it seems like Firefox, Chrome, and Safari all don't support it)

@ferdnyc
Copy link
Contributor

ferdnyc commented Jan 20, 2024

@wbamberg Fair question!

I think the definition of ::first-line in [SELECTORS-3] may be the overriding one, and it doesn't mention any such delegation. Only:

The ::first-line pseudo-element is similar to an inline-level element, but with certain restrictions. The following CSS properties apply to a ::first-line pseudo-element: font properties, color property, background properties, ‘word-spacing’, ‘letter-spacing’, ‘text-decoration’, ‘text-transform’, ‘line-height’. UAs may apply other properties as well.

@ferdnyc
Copy link
Contributor

ferdnyc commented Jan 20, 2024

(Or, well, not overriding, but what's implemented at the moment. [CSS-PSEUDO-4] perhaps isn't implemented in the browsers yet?)

@ferdnyc
Copy link
Contributor

ferdnyc commented Jan 20, 2024

CanIUse entry for ::first-line also cites SELECTORS-3 as the spec that defines it.

wbamberg pushed a commit to mdn/data that referenced this issue Jan 20, 2024
<!-- 🙌 Thanks for contributing! Adding details below will help us to
merge your PR faster. -->

<!-- Commits need to adhere to conventional commits and only `fix:` and
`feat:` commits are added to the release notes. -->
<!-- https://www.conventionalcommits.org/en/v1.0.0/#examples -->

### Description

Correct the `alsoAppliesTo` for the CSS `margin` and
`margin-{top,bottom,left,right.trim}` properties.

### Motivation

The data claims that `margin*` properties apply to the `::first-line`
pseudoelement, which is untrue. They apply to `::first-letter`, but not
`::first-line`. As reported by @Akindin in mdn/content#31806.

### Additional details

<!-- 🔗 Link to documentation, bug trackers, source control, or other
places providing more context -->

### Related issues and pull requests

Fixes mdn/content#31806
@dipikabh dipikabh removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants