-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Intro to HTML & CSS lesson | The cascade course: Rephrase sentence #26526
Conversation
@@ -26,7 +26,7 @@ A CSS declaration that is more specific will take precedence over less specific | |||
2. Class selectors | |||
3. Type selectors | |||
|
|||
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of anything less specific than it. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selector. | |||
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of less specific selector. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Typo
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of less specific selector. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selector. | |
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of less specific selector. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selectors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -26,7 +26,7 @@ A CSS declaration that is more specific will take precedence over less specific | |||
2. Class selectors | |||
3. Type selectors | |||
|
|||
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of anything less specific than it. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selector. | |||
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of less specific selector. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selectors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies @odilsonjs, my last suggestion was the wrong instance of "selector"
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of less specific selector. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selectors. | |
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of less specific selectors. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, i'll make a last small modifcation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, i think it's okay now
@@ -26,7 +26,7 @@ A CSS declaration that is more specific will take precedence over less specific | |||
2. Class selectors | |||
3. Type selectors | |||
|
|||
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of anything less specific than it. When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selector. | |||
Specificity will only be taken into account when an element has multiple, conflicting declarations targeting it, sort of like a tie-breaker. An ID selector will always beat any number of class selectors, <span id="high-specificity-class-type">a class selector will always beat any number of type selectors</span>, and a type selector will always beat any number of less specific selectors. When no declaration has a selector with a higher specificity, a greater specificity of a single selector takes precedence over a lesser specificity of the same selector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain to me what exactly this means with an example please @odilsonjs
"When no declaration has a selector with a higher specificity, a greater specificity of a single selector takes precedence over a lesser specificity of the same selector."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly! Let's illustrate this concept with a simple example in CSS:
Suppose you have the following CSS rules:
`/* Rule 1 */
p {
color: red;
}
/* Rule 2 */
#special-paragraph {
color: blue;
}`
Now, you have an HTML document like this:
<p id="special-paragraph">This is a special paragraph.</p>
In this example:
1 - The selector p in "Rule 1" has a lesser specificity because it's a type selector.
2 - The selector #special-paragraph in "Rule 2" has a greater specificity because it's an ID selector.
Since both selectors target the same
element, specificity becomes crucial in determining which style takes precedence. In this case:
- The "greater specificity" (ID selector) from "Rule 2" takes precedence over the "lesser specificity" (type selector) from "Rule 1."
As a result, the text in the paragraph will be displayed in blue, following the style defined by the ID selector in "Rule 2."
This example demonstrates how the specificity of selectors determines which styles are applied when there are conflicting CSS rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @odilsonjs, the first part of this paragraph is indeed about the rules you've just explained. However, the part you've changed is not. It's about when you are using the same kind of selectors.
For reference, the original text:
"When no declaration has a selector with a higher specificity, a larger amount of a single selector will beat a smaller amount of that same selector."
For example, when you are using class selectors, the declaration that uses more class selectors beats any that have less:
.list .item {
...
}
has a higher specificity than
.item {
...
}
The example that comes after this paragraph in the lesson demonstrates it.
I don't disagree the original line is confusing and wordy. But I'd argue the replacement text being proposed here is even more confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... okay @KevinMulhern, Thank you for your clarification
After some reflection, i finally get your point of view.
No changes is required about it
Let's keep this as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good to me too @odilsonjs - I can't think of a better alternative right now. Lets get this sentence reverted to the older version and then we'll merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, it's done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @KevinMulhern, this PR is still open, do you need some more changes before Merge?
This reverts commit f5cf57c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff, thanks @odilsonjs
Because
", and a type selector will always beat any number of anything less specific than it."
I think this is super confusing for students to understand. I rephrased it as: ", and a type selector will always beat any number of less specific selectors."
This PR
Issue
Closes #26523
Additional Information
Pull Request Requirements
location of change: brief description of change
format, e.g.Intro to HTML and CSS lesson: Fix link text
Because
section summarizes the reason for this PRThis PR
section has a bullet point list describing the changes in this PRIssue
section