Pseudo-elements and CSS content
A demo by Terry , presented as part of the article, Little Codes . He also writes on Medium .
Some of the possible uses of pseudo-elements:
Horizontal lines with text
This can be easily achieved with a
:before
pseudo element that spans the width of the parent container, and either assigning a height + background colour, or a border, to give an impression of a line.
This is the top content. Rendered her for put improved concerns his. Ladies bed wisdom theirs mrs men months set. Everything so dispatched as it increasing pianoforte. Hearing now saw perhaps minutes herself his. Of instantly excellent therefore difficult he northward. Joy green but least marry rapid quiet but. Way devonshire introduced expression saw travelling affronting. Her and effects affixed pretend account ten natural. Need eat week even yet that. Incommode delighted he resolving sportsmen do in listening.
This is the bottom content. As it so contrasted oh estimating instrument. Size like body some one had. Are conduct viewing boy minutes warrant expense. Tolerably behaviour may admitting daughters offending her ask own. Praise effect wishes change way and any wanted. Lively use looked latter regard had. Do he it part more last in. Merits ye if mr narrow points. Melancholy particular devonshire alteration it favourable appearance up.
Required form fields
We can also rely on pseudo-elements to add asterisks (*) to the end of form fields that are required as a visual indication. This hack requires some JS manipulation, since CSS lacks the ability to select siblings that are upstream.
Tooltips
We can also use pseudo elements to create interesting tooltips:
Ribbon
Pseudo-elements can also be used to create diagona ribbons, a common design motif today. This can be easily achieved by absolutely positioning the pseudo elements, and then rotating them by a desired angle.
Style 1
Style 2
Style 3
Style 4