Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use CSS pseudo elements to wrap some text in brackets?

Can I use CSS pseudo elements ::before and ::after to wrap some text in brackets?

i.e.

Text

becomes:

(Text)
like image 589
dbj44 Avatar asked Jan 08 '14 18:01

dbj44


People also ask

What is the use of pseudo-elements in CSS?

A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s). For example, ::first-line can be used to change the font of the first line of a paragraph. Note: In contrast to pseudo-elements, pseudo-classes can be used to style an element based on its state.

How do I wrap text in a box CSS?

CSS word-wrap property is used to break the long words and wrap onto the next line. This property is used to prevent overflow when an unbreakable string is too long to fit in the containing box.

How do I make a bracket in CSS?

Go to your CSS page and write the name of the section. For example: body, p, head, div class, etc. Put curly brackets: { } Inside of the curly brackets, state what you would like to change.

What is the correct syntax for styling before pseudo element?

::before (:before) In CSS, ::before creates a pseudo-element that is the first child of the selected element. It is often used to add cosmetic content to an element with the content property. It is inline by default.


1 Answers

Yes you can

http://jsfiddle.net/GHL6u/

<span>text</span>

span:before {
    content: '(';
}

span:after {
    content: ')';
}
like image 191
Christopher Marshall Avatar answered Oct 24 '22 20:10

Christopher Marshall