CSS Lesson 1

What is CSS?

CSS stands for Cascaded style Sheets. Its is collection of formatting styles, which can be applied to a web page. The style sheet consists of the following components:

How to create a CSS file and link it to your HTML file.

Open any folder in your work space and create a new file and name it as 'main.css'. you can edit it in text editor, but I suggest Sublime Text 3 for that purpose. Create a HTML file and in its <head></head> section, write this command:-
<link href="main.css" rel="stylesheet"/>







Another Easy way to write CSS directly into HTML file is to Write the CSS commands in <style>.........</style> tag of HTML file.

Now, your HTML file and CSS file files are linked, whatever you will write in CSS file will affect your HTML when you will run it in your browser

Style Rule

(a) Selector : A selector is a string that identifies what elements the correspond rule applies to amd is the first part of the rule.

(b) Declaration : This apart of the rule is enclosed within curly brackets. A declaration has two sessions separated by a colon. The section before the colon, is the value of that property.

The Syntax of a style rule is as follows:-
         Selector {property: value}
where,
Selector = Any HTML tag.
Property = Attribute like font, font size, font color.
Value = Setting for the attribute.
Example:-
             h1 {
             color: blue
                   }

























Similarly, by this method you can style many things. You just have to now the command for it.

Grouping Style Rules.

LIke in the above example, I just wanted to color only h1, what if i want to color h1 and h2 both in one command:-
Example:-
I hope you liked this CSS Lesson. I will continue to give Web- development basics lessons to you. Next Lesson: CSS Lesson 2

Comments

Popular posts from this blog

How to get Traffic on new Blog.

How fix Blank Adsense Ads in Blogger?

How to check and fix broken links in your blog?