Learn CSS Through Code Examples


While, we use HTML to create a web page, both JavaScript and CSS (Cascading Style Sheets) make the page attractive and more user-friendly. As can be seen, CSS adds style to HTML elements that make the website look professional. Although you can provide style to each element within the HTML document, still separating style definition from the markup makes the website easy to update and maintain. In this article, you will Learn CSS Through Code Examples.

Learn CSS Through Code Examples

  1. Use CSS to set the background color of different elements. Set the text color of different elements. Align the text. Decorate the text. Control the letters in a text. Indent text. Set the font, font size, and font style of the text. Add links. Add different colors to visited/unvisited links. Specify the background color for links.
  2. Use CSS to set an image as the background of a page. Position the background image. Repeat a background image only horizontally.
  3. Create transparent images using CSS. Create a transparent box with text on a background image.
  4. Write a CSS rule that makes all text size as 18pt and color like red, background-color blue. Give the heading style font size as 24pt, font family as sans-serif, color black, and text-align as Centre.
  5. Write a CSS rule for EM, H1, and P elements. Create Class attributes that apply a style class and inheritance
  6. Write an external linking style sheet to create a website that shows the different courses in your institute
  7. Write a program to show the conflicting style
  8. Create a site of the Solar System and insert an image of planets and position the style as absolute and give a proper margin as top, left, right and bottom
  9. Write a CSS rule that sets the three box dimension and aligns the text. The first box should be 20%, the second division should be 80% and the center aligns. And in the third division give a proper height and width.


This article on Learn CSS Through Code Examples provides CSS examples that help you getting familiar with CSS and adding style elements to HTML elements.


You may also like...