WordPress.org

Make WordPress Core

Opened 3 weeks ago

Last modified 2 weeks ago

#49318 reopened enhancement

Twenty-Twenty: content font CSS selector is too important

Reported by: alexandreb3 Owned by: ianbelanger
Milestone: 5.3.3 Priority: normal
Severity: normal Version: 5.3
Component: Bundled Theme Keywords: has-patch needs-dev-note fixed-major
Focuses: css Cc:

Description

The CSS selector used to define the content font-family is too important.

https://themes.trac.wordpress.org/browser/twentytwenty/1.1/style.css?rev=122235#L3524

.entry-content p,
.entry-content ol,
.entry-content ul,
.entry-content dl,
.entry-content dt {
        font-family: NonBreakingSpaceOverride, "Hoefler Text", Garamond, "Times New Roman", serif;
        letter-spacing: normal;
}

As a result, it's very difficult to override without custom CSS (especially for beginners that doen't code). Even a page builder can't edit the font without custom CSS (example with Elementor here https://youtu.be/FW-6rbDd4WI)

Why not only use this to set the default font ?

.entry-content{
        font-family: NonBreakingSpaceOverride, "Hoefler Text", Garamond, "Times New Roman", serif;
        letter-spacing: normal;
}

This way the main font-family is set for all the content and can be easily customized without custom CSS.

Attachments (2)

49318.diff (602 bytes) - added by larrach 3 weeks ago.
first patch
49318.1.diff (1.2 KB) - added by audrasjb 3 weeks ago.
Added RTL styles

Download all attachments as: .zip

Change History (11)

@larrach
3 weeks ago

first patch

#1 @larrach
3 weeks ago

  • Keywords has-patch needs-testing added

Hi,
I made a first patch for this ticket, I think it's worth testing this patch to look for indesirables effects.
cheers
Rach

@audrasjb
3 weeks ago

Added RTL styles

#2 @audrasjb
3 weeks ago

  • Keywords dev-feedback added; needs-testing removed
  • Milestone changed from Awaiting Review to 5.4

Hi @alexandreb3 and welcome to WordPress Core Trac,

This demand makes sense to me.

49318.1.diff should fix the issue for both LTR and RTL stylesheets. It works fine on my side on a fresh install.

Ping @ianbelanger for a detailed review.

#3 @ianbelanger
3 weeks ago

  • Keywords commit added
  • Owner set to ianbelanger
  • Status changed from new to reviewing

This looks good @audrasjb, marking for commit

#4 @ianbelanger
3 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 47133:

Bundled Themes: Twenty Twenty content font CSS selector is too important.

This makes the font family selector for entry-content less specific and thus easier to override.

Props alexandreb3, larrach, audrasjb.
Fixes #49318.

#5 @ianbelanger
3 weeks ago

  • Keywords fixed-major added
  • Milestone changed from 5.4 to 5.3.3
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backport

#6 @audrasjb
3 weeks ago

  • Keywords needs-dev-note added

#7 @audrasjb
3 weeks ago

  • Keywords dev-feedback commit fixed-major removed
  • Milestone changed from 5.3.3 to 5.4
  • Resolution set to fixed
  • Status changed from reopened to closed

Hi,
As per yesterday’s devchat and previous discussions in the minor release squad, let's move all Bundled Themes tickets from milestone 5.3.3 to 5.4 as there is no plan for a 5.3.3 release for now (except if it's a security release, which may of course happen at any time).

#8 @ianbelanger
3 weeks ago

  • Keywords fixed-major added
  • Milestone changed from 5.4 to 5.3.3
  • Resolution fixed deleted
  • Status changed from closed to reopened

Hi @audrasjb, this has already been committed and then reopened for backport, that is why it was in the 5.3.3 milestone and tagged with fixed-major. I am going to move it back into 5.3.3 and reopen. Thanks

Last edited 3 weeks ago by ianbelanger (previous) (diff)

#9 @alexandreb3
2 weeks ago

Hi,

With additional testing I noticed that the enhancement had an impact on content headings (they don't have the correct font anymore).

To fix this, we need to update the code as the following :

/* Font Families ----------------------------- */
​
.entry-content{
	font-family: NonBreakingSpaceOverride, "Hoefler Text", Garamond, "Times New Roman", serif;
	letter-spacing: normal;
}
​
.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6,
.entry-content cite,
.entry-content figcaption,
.entry-content .wp-caption-text {
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
}
​
@supports ( font-variation-settings: normal ) {
​
	.entry-content h1,
	.entry-content h2,
	.entry-content h3,
	.entry-content h4,
	.entry-content h5,
	.entry-content h6,
	.entry-content cite,
	.entry-content figcaption,
	.entry-content .wp-caption-text {
		font-family: "Inter var", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, sans-serif;
	}
}
Note: See TracTickets for help on using tickets.