FacebookTwitter

Adding a CSS file to your HTML page

By on Jan 25, 2014 in Beginners, CSS, HTML, Intermediate

CSS is very useful, it allows you to style your website to your taste. It is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. There are multiple was of using CSS and adding it to an HTML page. In this short tutorial I will show you a few ways of adding CSS to your website. First things first, Create a CSS file Open your favorite text editor (if you don’t have one get one choosing a text editior) and create a new file with extension .css. Once you have the file you can start declaring your styles using ‘tags’, ‘classes’, ‘ids’ and or a combinations of all of them. What are classes, ids, and tags The class selector is used to specify a style for a group of elements. The class selector is most often used on several elements.This allows you to set a particular style for many HTML elements with the same class.The class selector uses the HTML class attribute, and is defined with a “.”In the example below, all HTML elements with class=”red-background” will have a red background: ?View Code CSS1 2 3 4 #para1{ text-align:center; color:red; } You can also declare global attributes for HTML tags such as p, div, li, ul etc. And this is done in the same format as above: ?View Code CSS1 2 3 4 p{ text-align:center; color:red; } You can also...