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

Intro to HTML & CSS lesson | The cascade course: Rephrase sentence #26526

Merged
merged 7 commits into from
Oct 24, 2023

Conversation

odilson-dev
Copy link
Contributor

@odilson-dev odilson-dev commented Oct 19, 2023

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

  • Rephrase the sentence to: ", and a type selector will always beat any number of less specific selectors."

Issue

Closes #26523

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

@github-actions github-actions bot added the Content: Foundations Involves the Foundations content label Oct 19, 2023
@@ -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.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Typo

Suggested change
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.

Copy link
Contributor Author

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.
Copy link
Member

@KevinMulhern KevinMulhern Oct 20, 2023

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"

Suggested change
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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.
Copy link
Member

@KevinMulhern KevinMulhern Oct 21, 2023

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."

Copy link
Contributor Author

@odilson-dev odilson-dev Oct 21, 2023

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, it's done!

Copy link
Contributor Author

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?

Copy link
Member

@KevinMulhern KevinMulhern left a 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

@KevinMulhern KevinMulhern merged commit f74aad3 into TheOdinProject:main Oct 24, 2023
1 check passed
@odilson-dev odilson-dev deleted the newbranch branch October 24, 2023 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content: Foundations Involves the Foundations content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Cascade: Rephrase a sentence for better understanding
2 participants