Make WordPress Core

Opened 2 years ago

Closed 13 months ago

#57463 closed feature request (wontfix)

Twenty Twenty Three has no base styles for <table>

Reported by: helgatheviking's profile helgatheviking Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.1.1
Component: Bundled Theme Keywords: reporter-feedback close
Focuses: Cc:

Description

I am seeing that Twenty Twenty Three has no styles period, but I find this strange. As a plugin author who tries my best to inherit the theme's styles.... well that's not possible when there aren't styles. One of my plugins renders a <table> and I would prefer it to look like any other tables on the site, but there is no style to inherit.

I tried adding a wp-block-table class to a wrapper, but that doesn't help either since the style for the table block is in core and only loads when the table block is present.

What's the best suggestion here? I can style my own tables, but then they are destined to look different from the theme and it's not practical to provide different styles for every theme.

Change History (7)

#1 @poena
2 years ago

  • Component changed from Themes to Bundled Theme

#2 @sabernhardt
2 years ago

Thanks for the report!

This could be a bigger issue than just the bundled themes. Twenty Twenty-Two does not have basic table styles either. Other block themes such as Jaxon and EduBlock do not have them, but Greenshift does.

To work around that and to avoid overriding theme styles, you could try using the :where() selector.

	:where(table) {
		border-collapse: collapse;
		width: 100%;
	}
	:where(th, td) {
		border: 1px solid;
		padding: 0.5em;
	}

#3 @poena
2 years ago

Hi!
It is not possible for a theme to make sure that all plugins are styled.

My first recommendation would be to use the table block instead of a custom table in your custom plugin. I do understand that is not always possible.

In your plugin, you can enqueue the block style by referring to it's block slug. Then it is loaded even if the block itself is not present.
-It will load as an extra, separate, css file.

Basic example for the frontend:

function prefix_test() {
	wp_enqueue_style( 'wp-block-table' );
}
add_action( 'wp_enqueue_scripts', 'prefix_test' );

Aside: Note that the block places the wp-block-table class on the wrapping
figure element and not on the table.

Last edited 2 years ago by poena (previous) (diff)

#4 @poena
20 months ago

@helgatheviking Hi, I'm checking in to see if the suggestion above solves the problem.

#5 @poena
15 months ago

  • Keywords reporter-feedback added

#6 @karmatosed
13 months ago

  • Keywords close added

Whilst I understand this might be an issue for your table @helgatheviking in this case I am not sure I agree that all default themes should have styling for tables, particularly with the table block having default styling itself. I am wondering if the recommendation a while ago therefore from @poena does resolve this and as a tentative recommendation will add the close keyword. We can always review this.

#7 @karmatosed
13 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

As this has sat for a little while to get feedback I am now going to progress this to closed. Thank you everyone.

Note: See TracTickets for help on using tickets.