css last letter selector [duplicate] - css

This question already has answers here:
Change last letter color
(8 answers)
Closed 8 years ago.
Is there a way to style just the last letter in CSS?
I know that for the first letter I can use:
p::first-letter {
color: red;
}
But how to style the last letter?

There is no last-letter selector instead wrap it in span and style it
p::first-letter, p span {
color: red;
}
<p>test test tes<span>t</span></p>

Related

what is the 'a' that is added to CSS classes [duplicate]

This question already has answers here:
What does the ">" (greater-than sign) CSS selector mean?
(8 answers)
Closed 1 year ago.
so I have this CSS file and it has this
.post > a {
position: absolute;
color: #fff;
font-size: 22px;
cursor: pointer;
}
and I'm not sure what does the a means exactly?
Selects all <a> elements where the parent is an element with a class post.
https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator

Selecting parent to use `:not()` operator without child element is possible? [duplicate]

This question already has answers here:
Is there a CSS parent selector?
(33 answers)
Closed 1 year ago.
I am trying to apply color only parent level, by using :not() operator. but no result. is it possible?
html:
<header>title <span>123</span></header>
CSS:
header:not(header span){
color: green;
}
<header>title <span>123</span></header>
header:not(header span){
color: green;
}
I would use two css rules, one specifically targeting the span to unset the color: green rule applied by the header css rule.
header {
color: green;
}
header span {
color: initial;
}
<header>title <span>123</span></header>

Whether css text-transform capitalize make other letters lowercase? [duplicate]

This question already has answers here:
CSS text-transform capitalize on all caps
(15 answers)
Transform ALL CAPS to Proper Case using CSS and jQuery
(2 answers)
Closed 4 years ago.
By definition, text-transform: capitalize capitalizes the first letter of each word in the selected text. But it only works for the lowercase text. My text is all uppercase, how can I use css text-transform to make the first letter uppercase and other letters lowercase?
::first-letter can be used to select the first letter from the first line of block-level elements.
p {
text-transform: lowercase;
}
p::first-letter {
color: red;
text-transform: capitalize;
}
<p class="capitalize">lowercase</p>
<p class="capitalize">UPPERCASE</p>

first-child doesn't work in tbody? [duplicate]

This question already has answers here:
CSS selector for first element with class
(23 answers)
Can I combine :nth-child() or :nth-of-type() with an arbitrary selector?
(8 answers)
Closed 5 years ago.
I'm trying to select the first td.is-active inside my tbody. The .is-active style is well accepted, but it's impossible to add a radius to the first (and only first) .is-active.
Full code here.
Or just my SCSS:
td {
&.is-active {
background-color: $color5;
&:first-child {
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
}
}
}
An idea ? Thanks.
CSS properties are not cumulative and do not support sub-selection. td.is-active:first-child will not select the first element within the .is-active group. It will select the first td if it has the .is-active class, and no td matches this condition.
td:first-child will always select the first td, regardless of its class.
You are looking for the :first-of-class selector, which, unfortunately, doesn't exist.

Canceling changes to an individual element in CSS [duplicate]

This question already has answers here:
Apply CSS Style on all elements except with a SPECIFIC ID
(3 answers)
Closed 6 years ago.
How do I cancel the changes to one individual element in CSS?
Example:
a {
text-decoration: line-through;
color: green;
}
Now I would like at the end, a.test to ignore all rules and be displayed in the default way.
The normal colors and decorations of a link would show up on a page without any CSS influence.
All I found was to change every property that changes the element to initial. Is there a universal command that would exempt a.test from all changes?
You can exclude with the :not() CSS pseudo selector
a:not(.test) {
text-decoration: line-through;
color: green;
}
Demo: https://jsfiddle.net/azizn/d17vdf35/

Resources