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

Correct pseudo class selector #37168

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
2 changes: 1 addition & 1 deletion files/en-us/web/css/_doublecolon_part/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ tabbed-custom-element::part(tab):hover {
color: white;
}

tabbed-custom-element::part(tab active) {
tabbed-custom-element::part(tab):active {
Copy link
Member

Choose a reason for hiding this comment

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

The original is correct.

All part names used in ::part() pseudo-element must be present in the part value declared on the shadow tree element but the order of the part names doesn't matter, i.e., the selectors ::part(tab active) and ::part(active tab) are the same.

In the HTML, we have <div part="tab active">Tab A</div>. The ::part(tab active) matches that.

Copy link
Author

@andmperotti andmperotti Dec 10, 2024

Choose a reason for hiding this comment

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

Oh ok I understand now thank you.
I guess I was stuck on what I thought was using the 'active' pseudo class for styling the active div tab the user interacts with, and not just the 'active' part value tab.

And if you wanted the tabs to have a blue bottom border when active, here I changed 'active' part value to 'default' and use the active pseudo class selector.
tabbed-custom-element::part(tab) {
color: blue;
border-bottom: transparent solid 4px;
}

tabbed-custom-element::part(tab):hover {
background-color: black;
color: white;
}

tabbed-custom-element::part(tab default) {
border-color: blue;
}

tabbed-custom-element::part(tab):active {
border-color: blue;
}

Sorry I'm rambling but wanted to get this knot untangled in my brain.

Copy link
Member

Choose a reason for hiding this comment

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

would changing "active" to "hilite" in the HTML and CSS make it less confusing?

border-color: blue !important;
}
```
Expand Down
Loading