Utilizing pseudo-element selectors like :before
and :after
(or ::before
and ::after
) allows for the generation of dynamic content in browsers, known as generated content. This content is not part of the document's DOM, making it invisible to tools like screen readers.
This feature acts like a template; for example, it can be used to insert icons before list items, display URLs next to links when printed, or add appropriate quotation marks around quotes based on language.
For a practical demonstration, check out this fiddle:
ol.warning::before {
background-image: url('https://i.postimg.cc/bYW5CQF7/6897039.png');
background-size: 20px 20px;
display: inline-block;
width: 20px;
height: 20px;
content: "";
}
ol.warning::after {
content: " (This is very important!)";
color: red;
}
<ol class="warning">Having No Regular Checkups</ol>
If you make regular checkins at the gluten free aisle, but not with your doctor, that needs to change. Checking your health with a weigh in, stress test, and blood workup is critical.
<ol class="warning">Leading A Sedentary Lifestyle</ol>
If you spend most of the day sitting and don’t have an exercise plan or routine, time to take action. Get a plan for daily movement and make sure weights are part of the equation.
<ol class="warning">Eating Too Much </ol>
If you sure your microwave plastics are BPA free, but fill them with too many calories of processed food, time to count calories. While you are at it, make sure your food comes from good sources and drink more water.
<ol class="warning">Staying Sleep Deprived</ol>
If you are tired, that is not a badge of honor. That is a health hazard sign of the highest importance. Get 8 hours a night, don’t hit the snooze button, and get away from your phone an hour or more before bedtime.
<ol class="warning">Texting And Driving</ol>
No LMAO text or snapchat streak is worth your health or the health of someone else. Learn to view this as important as fastening your seatbelt.
<!-- content from https://www.trainingforwarriors.com/the-20-most-dangerous-things-you-are-still-doing/ -->
You have the flexibility to update the template content collectively rather than individually for each point, allowing for easy modifications when needed.
References:
- Learning Web Design: A Beginner's Guide to HTML, CSS, JavaScript, and Web Graphics
- Learning To Use The :after And :before Pseudo-Elements In CSS