HTML/CSS Service

Advanced CSS Pseudo Elements

Category: CSS, CSS3 Tutorial    |    375 views    |    Add a Comment  |   

 

First letters and First lines

The first-letter pseudo element applies to the first letter of an element and first-line to the top line of an element. You could, for examples create drop caps and a bold first-line for paragraphs like this:

p:first-letter {
	font-size: 3em;
	float: left;
}

p:first-line {
	font-weight: bold;
}

Before and after

The before and after pseudo elements are used in conjunction with the content property to place content either side of an element without touching the HTML.

The value of the content property can be open-quoteclose-quoteno-open-quoteno-close-quote, any string enclosed in quotation marks or any image using url(imagename). Read more…

Share/Save/Bookmark

 

CSS PSEUDO-ELEMENTS

Category: CSS, CSS 2 Tutorial, CSS Examples, CSS Tips, CSS Tutorials    |    280 views    |    Add a Comment  |   

Pseudo-elements can only be applied to the last “simple selector in a chain”, as the recommendation says. A simple selector is either the univeral selector (*) or a type selector (I tend to call them element selectors) followed by attribute, ID or pseudo-class selectors.

CSS2  has four of them:

  • :first-line allows you to style the first line of a block element
  • :first-letter allows you to style the first letter of a block element
  • :before allows you to inject and style content before an element, block or inline.
  • :after allows you to inject and style content after an element, block or inline.

Read more…

Share/Save/Bookmark