InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS properties

  • CSS3 flexbox
  • all
  • animation
  • background-color
  • background-image
  • border
  • border-color
  • border-radius
  • border-style
  • border-width
  • bottom
  • box-shadow
  • box-sizing
  • calc function
  • clip
  • color
  • color value currentColor
  • color values
  • cursor
  • float
  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • generated content
  • left
  • letter-spacing
  • line-height
  • list-style
  • list-style-image
  • list-style-position
  • list-style-type
  • margin
  • max-height
  • max-width
  • min-height
  • min-width
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • padding
  • pointer-events
  • position
  • resize
  • right
  • text-align
  • text-decoration
  • text-indent
  • text-overflow
  • text-shadow
  • text-transform
  • top
  • transform
  • transition
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • visibility
  • white-space
  • word-break
  • word-spacing
  • word-wrap/overflow-wrap
  • z-index
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties

CSS generated content for ::after and ::before

on Apr 18, 2016

CSS property content is used with the ::before and ::after pseudo-elements to generate content in a document.

CSS property content

CSS version: CSS 2.1
Value: normal | none | [ string | uri | counter | attr(identifier) | open-quote | close-quote | no-open-quote | no-close-quote ]+
Initial: normal
Applies to: ::before and ::after pseudo-elements
Inherited: no

Example – display url after a tag text using content

<style type="text/css">
a::after {
  content: " [" attr(href) "]";
}
</style>

<a href="https://infoheap.com/">link1</a>
refresh done
try it online

Example – display fixed string before a tag text

<style type="text/css">
a::before {
  content: " | ";
}
</style>

<a href="https://infoheap.com/">link1</a>
refresh done
try it online

Example – display img before a tag text

<style type="text/css">
a::before {
  content: url(/img/star_10x10.png);
}
</style>

<a href="https://infoheap.com/">link1</a>
refresh done
try it online

Example – automatic quote around p tag text

<style type="text/css">
p::before {
  content: open-quote;
}
p::after {
  content: close-quote;
}
</style>

<p>Content inside p tag</p>
refresh done
try it online

Related

  • CSS ::first-line pseudo element
  • CSS ::first-letter pseudo element
  • CSS ::before and ::after examples

Specification

  • W3C CSS 2.1 content specification

Suggested posts:

  1. CSS selector specificity
  2. CSS resize – make block element resizable by user
  3. WordPress – write custom php log to separate file
  4. CSS calc function for numeric values
  5. Running php eval on code with tags
  6. CSS flexbox – display flex and inline-flex
  7. Javascript – get computed style of an element
  8. How to customize wordpress image alt tag
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress