The short answer is: no, you cannot use CSS to target the text within the element independently of the content of the pseudo elements.
However, you can create a work around by pasting the content of the pseudo element over the original
content and thus hide it.
Note: This approach uses absolute positioning so it may created issues if the pseudo-element
content is excessively long.
Better Approach: An alternative approach is to use the visibility
property to hide the main content of the
element but make visible the content from the pseudo-elements (credit to Hidden-Hobbes).
#element::before {
content: "My new text.";
display: block;
color: black;
position: absolute;
background-color: yellow;
width: 100%;
}
#element {
color: red;
position: relative;
}
#element-alt::before {
content: "My new alt-text.";
border: 1px dotted blue;
visibility: visible;
display: block;
}
#element-alt {
border: 1px dotted gray;
margin-top: 30px;
visibility: hidden;
}
<div id="element">This is the original text.</div>
<div id="element-alt">This is the original text.</div>