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
0 answers

Why :after does not work in IE8

I am trying to give the following style: .myclass{content: "\2a";} it works in all browsers except IE8. In IE8 as well, it works on giving alerts. I think its trying to apply style before the element is loaded. How do I deal with it? I…
appy
  • 3
  • 5
0
votes
3 answers

Footer wont meet the right edge of a re-sized window

Before I start I'd like to note that I'm very new to HTML and I am self teaching. I just started recently and still have much to learn. My issue seems simple yet I can't seem to figure it out. Everything else on the page is fine, it's just the…
Piece Digital
  • 161
  • 1
  • 10
0
votes
1 answer

unable to find the reference to the content property in a stylesheet

Firstly let me admit that I am a beginner in CSS. I recently came across a nice website: http://www.sitepoint.com/better-solution-managing-z-index-sass/ and was curious to know how the "3" is displayed alongside "CSS". When I tried to check through…
zilcuanu
  • 3,451
  • 8
  • 52
  • 105
0
votes
1 answer

How to set "content" on an :after element inline with the text

I have an li-tag in my menu: nav ul li ul.firstmenu li.secondtothree{ float: none; border-bottom: 1px solid #DCDCDA; padding:3px; text-transform:none; } Then I want to add ">" after the menupoints, so that it looks like "Home >" or "Article…
Zwen2012
  • 3,360
  • 9
  • 40
  • 67
0
votes
3 answers

Why element has various height depending on whether it has content or not

I am curious to know why following elements have various heights: i { display: inline-block; width: 1em; height: 1em; } i.icon:before { content: 'Ω'; } i.noicon:before { content: ''; …
Jake
  • 99
  • 1
  • 11
0
votes
1 answer

Is it possible to load a background image via attribute with CSS?

I was wondering, if I could use CSS to load a background if the attribute gets a specific class. To demonstrate, it should load on hover. HTML
Simon Ferndriger
  • 4,455
  • 6
  • 28
  • 53
0
votes
0 answers

'content' property not working with :hover on IE

The content property isn't working with a :hover selector on any version of IE HTML: Help Button CSS: .helpButton:hover {content:url(../images/helpButton-hover.png); cursor:…
Ben
  • 213
  • 4
  • 13
0
votes
0 answers

HTML5's 'data-' attribute overriding CSS 'content' property

I've looked far and wide and have been unable to find an explanation to this behavior. Why does HTML5's data- attribute override my CSS content property on a common element? So for example, I have the following element defined:
KodeKreachor
  • 8,852
  • 10
  • 47
  • 64
0
votes
1 answer

How to do CSS text replacement using generated :before or :after without absolute positioning?

I'm attempting to allow our CMS editors the ability to swap out the text used for a page title using only a css override.
This Page's Default Title
Using the :before or :after tag, one…
0
votes
1 answer

Parallax scroll a background image into permanent view

The affect I'm going for is something I can only compare to Google+ top navigation effect and through some parallax into that. That is, when you scroll down, the search bar disappears and your left with a small "toolbar". I found some jQuery to help…
Jeremy
  • 310
  • 1
  • 5
  • 18
0
votes
1 answer

CSS before counter not working on div

I'm having trouble displaying content before input element. http://plnkr.co/edit/9UC93nnNm6vmmLEIYDJK?p=preview On this plunker you can see input:before should display something, but it's not displaying anything 1) If I change it to p:before it…
Slaven Tomac
  • 1,552
  • 2
  • 26
  • 38
0
votes
1 answer

displaying image and text within the same DIV through content

I am creating a print CSS for IE browser, within which I have to add text and an image in a div through CSS. I am using content to add text and background to add an image, but somehow Image is not being shown. This is how I'm doing. #header…
Steve
  • 2,546
  • 8
  • 49
  • 94
0
votes
1 answer

Selection and insert content to a link with :before with class name does not work

Why doesn't the following work: HTML: CSS: .vcard a.email:before { content: "Contact…
Daniel Ramirez-Escudero
  • 3,877
  • 13
  • 43
  • 80
0
votes
0 answers

CSS set content of element to image

I've got the following class, which works in all the major browsers except Firefox for PC. Specifically the issue is with the content being on a regular element—Ffx doesn't seem to like it on anything except a ::before or ::after pseudo-element.…
Jakob Jingleheimer
  • 30,952
  • 27
  • 76
  • 126
0
votes
2 answers

jquery remove based on before content

Is it possible to write a JQuery function that will remove everything with a specific :before content. here is an example statement to give you something to show me with code: remove all elements in the document that have a :before pseudo element…
Ryan Saxe
  • 17,123
  • 23
  • 80
  • 128
1 2 3
11
12