CSS Pseudo-element

pseudo-element ត្រូវ​គេ​យក​ទៅ​ប្រើប្រាស់​សំរាប់​រចនា​ផ្នែក​ផ្សេង​ៗ​របស់ element មាន​ដូចជា​តួ​អក្សរ​ទី​មួយ ឬ​បន្ទាត់​ទី​មួយ បន្ថែម content នៅ​ខាង​មុខ​និង​ឬ​ខាង​ក្រោយ element ជា​ដើម​។

::first-line pseudo-element ត្រូ​គេ​ប្រើប្រាស់​សំរាប់​រចនា​កែច្នៃ​បន្ទាត់​ទី​មួយ​របស់​អត្ថបទ​មាន​នៅ​ក្នុង​ element ទាំងឡាយ​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>Pseudo-element</title>
    <style>
      p::first-line {
  		color: #ff0000;
  		font-variant: small-caps;
	  }
    </style>
  </head>
  
  <body>
	

You can use the ::first-line pseudo-element to add a special effect to the first line of a text. Some more text. And even more, and more, and more, and more, and more, and more, and more, and more, and more, and more, and more, and more.

</body> </html>

You can use the ::first-line pseudo-element to add a special effect to the first line of a text. Some more text. And even more, and more, and more, and more, and more, and more, and more, and more, and more, and more, and more, and more.


::first-letter ត្រូវ​គេ​យក​ទៅ​ប្រើប្រាស់​សំរាប់​កែច្នៃ​រចនា​តួ​អក្សរ​ទី​មួយ​នៃ​អត្ថបទ​មាន​នៅ​ក្នុង​ element ទាំងឡាយ​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>Pseudo-element</title>
    <style>
      p::first-letter {
  		color: #ff0000;
  		font-size: xx-large;
	  }
    </style>
  </head>
  
  <body>
	

You can use the ::first-letter pseudo-element to add a special effect to the first character of a text!

</body> </html>

You can use the ::first-letter pseudo-element to add a special effect to the first character of a text!


::before ត្រូវ​គេ​យក​ទៅ​ប្រើ​ប្រាស់​សំរាប់​បន្ថែម content នៅ​ពី​មុខ content របស់ element ទាំងឡាយ​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>Pseudo-element</title>
    <style>
      h1::before {
  		content: url(smiley.gif);
	  }
    </style>
  </head>
  
  <body>
	

This is a heading

The ::before pseudo-element inserts content before the content of an element.

This is a heading

Note: IE8 supports the content property only if a !DOCTYPE is specified.

</body> </html>

This is a heading

The ::before pseudo-element inserts content before the content of an element.

This is a heading

Note: IE8 supports the content property only if a !DOCTYPE is specified.


::after ត្រូវ​គេ​យក​ទៅ​ប្រើប្រាស់​សំរាប់​បន្ថែម content នៅ​ខាង​ក្រោយ​ element ទាំងឡាយ​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>Pseudo-element</title>
    <style>
      h1::after {
  		content: url(smiley.gif);
	  }
    </style>
  </head>
  
  <body>
	

This is a heading

The ::after pseudo-element inserts content after the content of an element.

This is a heading

Note: IE8 supports the content property only if a !DOCTYPE is specified.

</body> </html>

This is a heading

The ::after pseudo-element inserts content after the content of an element.

This is a heading

Note: IE8 supports the content property only if a !DOCTYPE is specified.


::selection ត្រូវ​គេ​យក​ទៅ​ប្រើប្រាស់​សំរាប់​ធ្វើការ​កែច្នៃ​រចនា​ផ្នែក​នៃ​អត្ថបទ​ដែល​ត្រូវ​បាន​ជ្រើសរើស​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>Pseudo-element</title>
    <style>
      ::-moz-selection { /* Code for Firefox */
  		color: red;
  		background: yellow;
	  }

	  ::selection {
  		color: red;
  		background: yellow;
	  }
    </style>
  </head>
  
  <body>
	

Select some text on this page:

This is a paragraph.

This is some text in a div element.

Note: ::selection is not supported in Internet Explorer 8 and earlier versions.

Note: Firefox supports an alternative, the ::-moz-selection property.

</body> </html>

Select some text on this page:

This is a paragraph.

This is some text in a div element.

Note: ::selection is not supported in Internet Explorer 8 and earlier versions.

Note: Firefox supports an alternative, the ::-moz-selection property.


ក្រៅ​ពី​ការបន្ថែម content នៅពី​ខាង​មុខ ឬ​ខាង​ក្រោយ element ទាំងឡាយ​ យើង​ក៏​អាច​ធ្វើការ​កែច្នៃ​រចនា content ដែល​ត្រូវ​បាន​បន្ថែម​នោះ​បាន​ដែរ ដោយ​ធ្វើ​ដូច​ខាង​ក្រោម​នេះ៖

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>Pseudo-element</title>
    <style>
      h1::after {
  		content: url(smiley.gif);
        position: relative;
 		top: 15px;
	  }
    </style>
  </head>
  
  <body>
	

This is a heading

The ::after pseudo-element inserts content after the content of an element.

This is a heading

Note: IE8 supports the content property only if a !DOCTYPE is specified.

</body> </html>

This is a heading

The ::after pseudo-element inserts content after the content of an element.

This is a heading

Note: IE8 supports the content property only if a !DOCTYPE is specified.