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
0
votes
1 answer

When using :before on an element it becomes the first child of said element?

I've always used :before in CSS to mean put content before the selector. I've never had any problems with this, however, I've stumbled across something that is confusing me where a selector's :before is appending inside the element instead of coming…
o_O
  • 5,527
  • 12
  • 52
  • 90
0
votes
1 answer

Safari showing :after pseudo-element as if is :before

Safari is showing my :after pseudo-element as if is a :before Chrome is showing it correctly, but Safari is not. It is supposed to put a forward slash after every link on the navigation except the last one, but Safari is putting them before each…
Keir
  • 111
  • 2
  • 6
0
votes
4 answers

first-letter initial quote doesn't work in firefox

I quite dont get it here, firefox doesn't want to accept ❝ (U-275D) as my first letter dispite the fact that they are supposed to accept initial quote. Does anybody have any idea ? http://jsfiddle.net/DXn3B/1/ .who { font-family: 'Open Sans',…
0
votes
0 answers

:before and :after content with parent element visibility issue

I have a container div that has an input type="checkbox" that has pseudo-elements added using ::before and ::after. function hiding() { var child = document.getElementById("child"); child.style.visibility = "hidden"; } var hide =…
Xion Dark
  • 3,374
  • 2
  • 15
  • 23
-1
votes
2 answers

How to make font awesome icon appear when setting it in content of css

Having this snippet: .my-style { padding: 0; list-style-type: none; } .my-style i { margin-right: 5px; } .my-style li { margin-bottom: 8px; } .my-style li::before { content: '\f00c'; display: inline-block; margin-left:…
Leo Messi
  • 5,157
  • 14
  • 63
  • 125
-1
votes
2 answers

Edit colour of text within CSS content

I would like to change the color of some text but the text is in the CSS property 'content'. Is there a way to select specific words and colorize them? For example here is the code I have .info:before { content: "PLEASE NOTE: this would be something…
-1
votes
1 answer

Mixed inline and block positioning of div content

What I want to acheive, by applying css styles is composition of content: I apply my style and I got result: li { position: relative; list-style-type: none; border: 1px; border-color: red; border-style: solid; } div { border:…
lissajous
  • 371
  • 5
  • 17
-1
votes
1 answer

How can I see the inside of the content box

Hi I was wondering how can I see what is inside this box "" in the content in the style sheet for example : I want to know the link of the image: .facebookicon::before { content: ""; }
-1
votes
2 answers

background-color on heading with pseudo-element

I am trying to make a heading with a trailing bar. I used the pseudo-element ::after. My problem is the background color of the heading should "block out" the part of the ::after element that is located "under" the heading itself - but it…
Brian Emilius
  • 717
  • 1
  • 8
  • 31
-1
votes
1 answer

HTML entities in CSS content (convert entities to escape-string at runtime)

I know that html-entities like   or ö or ð can not be used inside a css like this: div.test:before { content:"text with html-entities like ` ` or `ö` or `ð`"; } There is a good question with good answers dealing…
Hubert Schölnast
  • 8,341
  • 9
  • 39
  • 76
-1
votes
1 answer

Dynamically changing content of a SPAN

How can I dynamically change the content of a tag in an infinite loop. I have tried using the below method. Is it possible to do this with pure CSS animations? If it is not possible with pure CSS, please suggest an alternate…
karbz0ne
  • 11
  • 4
-2
votes
1 answer

vertical align :after with multi line text

I have a list of items. An item has a title and text. After the text I want a 'checked icon'. This icon must be aligned to the right and in de middle of the text. The problem now is that the icon is aligned at the bottom of the text; #main-box { …
Babulaas
  • 761
  • 3
  • 13
  • 47
1 2 3
11
12