Questions tagged [css-content]

CSS Generated Content allows us to insert and move content around a document. We can use this to create footnotes, endnotes, and section notes, as well as counters and strings, which can be used for running headers and footers, section numbering, and lists.

CSS Generated content, automatic numbering, and lists

CSS Generated Content allows us to insert and move content around a document. We can use this to create footnotes, endnotes, and section notes, as well as counters and strings, which can be used for running headers and footers, section numbering, and lists.

Authors specify the style and location of generated content with the :before and :after pseudo-elements. As their names indicate, the :before and :after pseudo-elements specify the location of content before and after an element's document tree content. The content property, in conjunction with these pseudo-elements, specifies what is inserted.

For example, the following rule inserts the string "Note: " before the content of every P element whose "class" attribute has the value "note":

p.note:before {
    content: "Note: ";
}

Examples

/* Keywords that cannot be combined with other values */
content: normal;
content: none;

/* <url> value */
content: url("http://www.example.com/test.png");

/* <image> value */
content: linear-gradient(#e66465, #9198e5);

/* values below can only be applied to generated content using ::before and ::after */

/* <string> value */ 
content: "prefix";

/* <counter> values */
content: counter(chapter_counter);
content: counters(section_counter, ".");

/* attr() value linked to the HTML attribute value */
content: attr(value string);

/* Language- and position-dependent keywords */
content: open-quote;
content: close-quote;
content: no-open-quote;
content: no-close-quote;

/* Except for normal and none, several values
   can be used simultaneously */
content: open-quote chapter_counter;

/* Global values */
content: inherit;
content: initial;
content: unset;

Resource

177 questions
7
votes
5 answers

content property in CSS

In some template I see that an arrow that created with CSS. something like this: div:after{ content:"\f107"; } this code display an arrow like this : what is this code? where I can find more codes?
Mohsen Safari
  • 6,669
  • 5
  • 42
  • 58
7
votes
4 answers

apply css to html but not iframe html

I'm making a user stylesheet for the add-on 'stylish.' It applies a semi-transparent dark box over the entire page for night-browsing. I'm using: html:before { content:url()!important; position:fixed!important; width:100%!important; …
fanfare
  • 1,827
  • 1
  • 21
  • 22
7
votes
1 answer

Influence of the z-index of an element on the z-index of :before / :after pseudo element

Here is a behavior I don't quite understand regarding z-index and css pseudo element ::before / ::after. It is illustrated on this jsfiddle : http://jsfiddle.net/jgoyon/T6QCf/ I created a positioned box and added content with ::after pseudo element…
jgoyon
  • 139
  • 8
7
votes
3 answers

using both :after and :hover

Is it possible to only display the :after pseudo using :hover? For example using alternative elements. #parent{} #child{display:none;} #parent:hover >#child{display:block;} As far as I've got with the same…
bashleigh
  • 8,813
  • 5
  • 29
  • 49
6
votes
1 answer

CSS make background-image use font character

I'd like to use a font character (e.g. from font-awesome) as a background-image of an input element.
6
votes
1 answer

Change fill color of data-URI SVG path in pseudo element

Is it possible to use CSS to change the color of a SVG path which is within a pseudo element data-URI? External Site CSS: a[href^="http://"]:after { content:…
6
votes
1 answer

Can't set font-weight on the :after pseudo-element used on elements

So, i've got a custom style on an input element, and I want to place some text on the input with the use of :after. The problem i'm running into is that i cannot seem to change the font-weight on the :after element, this problem only occurs with the…
koningdavid
  • 7,903
  • 7
  • 35
  • 46
6
votes
4 answers

css :after content not underlined

To seperate the links in navigation I have set the following #menu-main li a:after{ content: " * "; } The current item gets additional text-decoration: underline; my problem now is, that the " * " is also underlined, but shouldn't I have tried…
obs
  • 797
  • 3
  • 14
  • 37
5
votes
2 answers

Convert arabic numerals in roman numerals in pure CSS

I'm writing a custom theme for a website, so I cannot use Javascript. I would like to convert some numbers to roman numerals. I tried this: .score:before { counter-reset: mycounter attr(score number, 0); content: counter(mycounter,…
Antoine Pietri
  • 793
  • 1
  • 10
  • 25
5
votes
3 answers

how to add a dollar sign through css content

How can I display the "$" sign through CSS Content:" " I've tried all kinds of different codes. Putting just div.example {Content:"$1000";} displays on the site like "00". Trying to do this before resorting to Javascript.
Sana
  • 73
  • 1
  • 1
  • 5
5
votes
3 answers

Reading internationalized content from CSS file

I don't have much experience on UI development. I have a class defined in CSS, something like this- .myclass { color: red; content: "my content"; font-size: 12px; padding-right: 2px; } I want "my content" value to be…
AlwaysALearner
  • 6,320
  • 15
  • 44
  • 59
5
votes
2 answers

How to set the content property of an `after` pseudo-element to an attribute of a sibling form element

Is there any way, using CSS, to set the content of an after pseudo-element to an attribute of a sibling form element? For example: p:after{ content: +select(attr(title)); }

Message: