If you make the h2 content width by using a shrink to fit display type such as display:inline-flex then you can use left and right on the pseudo element to match exactly the width of the text (plus its padding) without using a magic number like 20%.
Change your 2 rules as follows.
.Resume h2 {
font-size: 40px;
padding: 50px;
letter-spacing: 4px;
font-weight: bold;
text-transform: uppercase;
display: inline-flex; /* shrink to fit*/
margin: 0;
position:relative;/* stacking context for pseudo element */
}
/* Pseudo element line */
/* Reaadpt line under education experience */
.Resume h2::after {
content: "";
/*display: block; not needed when position:absolute used in this case*/
position: absolute;
background-color: #7d7465;
height: 10px;
bottom:20px;
left: 0;/* match width of text and padding*/
right: 0;/* match width of text and padding*/
/* width: 20%;*/
}
If you want the line only under the text then use left:50px and right:50px to match your padding (or indeed remove left and right padding).
To avoid errors I suggest that you use lower case in your rules rather than saying .Resume use .resume instead. It just makes life easier
There are other ways to get the underline but I assume you were just practicing with the pseudo element anyway
Yes, in a previous post you suggested that I should give up CamelCase in my code. As I already started my code using it, I’m going to finish my website, then clean/polish my code and get rid of all CamelCase.
Yes you are right, I decided to use this approach to learn new things, especially use of pseudo-elements.
.Resume is NOT camelCase and I will always ask people to use camelCase because it is much easier to read. But of course you should use if correct. the first character is always lower case not upper case.
Although I have previously used camelCase in css my current approach is to use a hyphen instead and keep camelCase for JS only. I find that makes me more consistent.
In the end it’s purely a matter of choice but whatever you choose you need to stick to the plan and not go off piste:)