How to Create CSS

Be sure you have a basic understanding of HTML tags., Learn some of the basic CSS properties., Learn about values for each respective property., Learn about the style HTML attribute., Understand that inline CSS is not usually used for websites by...

21 Steps 3 min read Advanced

Step-by-Step Guide

  1. Step 1: Be sure you have a basic understanding of HTML tags.

    You should know how tags work and of the src and href attributes.
  2. Step 2: Learn some of the basic CSS properties.

    You will find that there are very many properties.

    However, it is not necessary to learn them all.

    Some good basic CSS properties to know are color and font-family. , All properties need a value.

    For the color property, for example, you might put the red value. , It is used within an element like href or src.

    To use it, within the quotation marks after the equal sign, put the CSS attribute, a colon, and then the value of the property.

    This is known as a CSS rule. , Inline CSS can add unnecessary clutter to an HTML document.

    However, it is a great way to get introduced to how CSS works. , It should allow you to create HTML and CSS files.

    If you don't have a special program installed, you can use Notepad or another text editor.

    Simply save your file both as a text file and a CSS file. , You should open this with an HTML editor as well, if you have one installed.

    HTML editors allow you to edit HTML and CSS at the same time. , This will let you write CSS without the need for a separate file. , To make your code more legible, always put the second curly brace on its own line. , Each line must end with a semicolon (;).

    To make your code legible, each rule should start on its own line and each line should be indented.

    It is very important to note that this styling will affect all elements of the selected type on the page.

    More specific styling will be covered in the next section. , Open your HTML file as well. , This will allow you to link a separate CSS file to your HTML document.

    Your link tag needs three attributes: rel, type, and href. rel means "relationship" and tells the browser what the relationship is to the HTML document.

    Here it should have a value of "stylesheet". type tells what type of media is being linked to.

    Here it should have a value of "text/css" href here is used similarly to how it is used in an <a> element, but here it must link to a CSS file.

    If the CSS file is located in the same folder as the HTML file, only the file name needs to be written within the quotation marks. , Add a class attribute to these elements and set them equal to a class name of your choice.

    This will give your elements the same styling. , Type the class name in your CSS file with a period (.) preceding it (i.e. .class). , Id's are created in CSS using a pound symbol (#) rather than a period.

    Id's are more specific than classes, so an id will override any class styling if it has an attribute with a different value than the class. , It is an official website aimed at teaching web development skills.

    The w3 has plenty of references listed for HTML and CSS, as well as other web languages. , Sites like CSS tricks.com specifically are aimed at teaching CSS and web design skills.

    Finding reputable sources will help you on your learning journey. , Their experience and know-how can teach you valuable knowledge and skills. , Viewing the CSS of well-developed websites can show you ways to design parts of websites.

    Copying it down as practice and fiddling with the code can help you learn how to use different CSS attributes.
  3. Step 3: Learn about values for each respective property.

  4. Step 4: Learn about the style HTML attribute.

  5. Step 5: Understand that inline CSS is not usually used for websites by professional web developers.

  6. Step 6: Launch the program you desire to use.

  7. Step 7: Open the HTML file for your website.

  8. Step 8: Create a <style> tag within your HTML head.

  9. Step 9: Choose an element you want to add styling to and type the name of the element followed by a set of curly braces ({ }).

  10. Step 10: Between the braces

  11. Step 11: type your CSS rules as you would using the style attribute.

  12. Step 12: Create a CSS file

  13. Step 13: not an HTML file and save it using the .css extension.

  14. Step 14: Create a <link> tag in your HTML head.

  15. Step 15: Select elements of different types you want to add the same styling to.

  16. Step 16: Assign what styling a class will receive.

  17. Step 17: Select single elements you want to add special styling to and add an id attribute.

  18. Step 18: Visit the w3 schools.

  19. Step 19: Find other sites specifically aimed at learning and teaching HTML and CSS.

  20. Step 20: Get in touch with web designers and developers.

  21. Step 21: View the source code of websites you come across.

Detailed Guide

You should know how tags work and of the src and href attributes.

You will find that there are very many properties.

However, it is not necessary to learn them all.

Some good basic CSS properties to know are color and font-family. , All properties need a value.

For the color property, for example, you might put the red value. , It is used within an element like href or src.

To use it, within the quotation marks after the equal sign, put the CSS attribute, a colon, and then the value of the property.

This is known as a CSS rule. , Inline CSS can add unnecessary clutter to an HTML document.

However, it is a great way to get introduced to how CSS works. , It should allow you to create HTML and CSS files.

If you don't have a special program installed, you can use Notepad or another text editor.

Simply save your file both as a text file and a CSS file. , You should open this with an HTML editor as well, if you have one installed.

HTML editors allow you to edit HTML and CSS at the same time. , This will let you write CSS without the need for a separate file. , To make your code more legible, always put the second curly brace on its own line. , Each line must end with a semicolon (;).

To make your code legible, each rule should start on its own line and each line should be indented.

It is very important to note that this styling will affect all elements of the selected type on the page.

More specific styling will be covered in the next section. , Open your HTML file as well. , This will allow you to link a separate CSS file to your HTML document.

Your link tag needs three attributes: rel, type, and href. rel means "relationship" and tells the browser what the relationship is to the HTML document.

Here it should have a value of "stylesheet". type tells what type of media is being linked to.

Here it should have a value of "text/css" href here is used similarly to how it is used in an <a> element, but here it must link to a CSS file.

If the CSS file is located in the same folder as the HTML file, only the file name needs to be written within the quotation marks. , Add a class attribute to these elements and set them equal to a class name of your choice.

This will give your elements the same styling. , Type the class name in your CSS file with a period (.) preceding it (i.e. .class). , Id's are created in CSS using a pound symbol (#) rather than a period.

Id's are more specific than classes, so an id will override any class styling if it has an attribute with a different value than the class. , It is an official website aimed at teaching web development skills.

The w3 has plenty of references listed for HTML and CSS, as well as other web languages. , Sites like CSS tricks.com specifically are aimed at teaching CSS and web design skills.

Finding reputable sources will help you on your learning journey. , Their experience and know-how can teach you valuable knowledge and skills. , Viewing the CSS of well-developed websites can show you ways to design parts of websites.

Copying it down as practice and fiddling with the code can help you learn how to use different CSS attributes.

About the Author

J

Joseph Graham

Dedicated to helping readers learn new skills in hobbies and beyond.

68 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: