Skip to main content

CSS Tutorial – Lesson 1 Part I

What is CSS?

CSS refers to Cascading Style Sheets, In general styles define how to display elements on the web page.

Why CSS?

By CSS, we can define a style for a web page and make it standard for all web pages on the website, changes to the style will be applicable to all pages on the same time. another point of view, CSS responsible for formatting elements of a page, this feature makes the HTML/XHTML responsible on defining the content of the page, and does not have a role in formatting the elements.

CSS created by W3C to solve a problem of HTML/XHTML, suppose you want to design your page in some specifications for fonts and colors used, then without using CSS, you have to write these specification for each page you want to apply this design to it, moreover, you might need to apply same design specifications on two different places on the same page, without CSS, you have to write it where ever you want it, this will make page design more complex and poor.

Syntax:

A CSS rule consists of two parts, first one is the selector, and the second one is the declaration part.

Normally, the selector is an HTML element that you want to style.

The declaration part, consists of properties and its values, each property defines a specific style that makes special touches to an element.

Example:

p

{

/* Declaration Part */

color: black;

font-size: 13px;

text-align: justify;

}

Notes:

  • The above lines of code, makes a rule for styling paragraphs in any HTML/XHTML document.
  • This rule displays paragraphs in font color black and size of 13px, and justifies it to its parent borders.
  • The p is an HTML element that refers to define paragraphs, and it is the selector in this rule.
  • Properties are defined in the declaration block.
  • Declaration block begins with an open curly bracket, and finishes with a close curly bracket.
  • Comments in CSS are enclosed within /* and */.
  • Each property definition ends with a semi-colon.
  • In this example I’m just showing the syntax of CSS, next lessons we’ll talk in deep details about properties and its values.

How to apply?

This example shows how to apply the above rule in an XHTML document.

  • Firstly, save the above rule in a file for example style.css, it is important that the extension of the file be .css.
  • In each page you need to apply your style, just link the style sheet to your page.
  • Look at this example:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html>

    <head>

    <!—Use the link tag to link to your style sheet –>

    <link rel="stylesheet" type="text/css" href="style.css" />

    <title>Welcome</title>

    </head>

    <body>

    <p> This is a paragraph that has special style defined in the CSS style sheet. </p>

    <p> Another Paragraph has same styles it is amazing idea Smile</p>

    </body>

    </html>

    End of Part I.

    To download this part as PDF file click here: CSS Tutorial – Lesson 1 Part I

    Best Wishes,

    Anas Jaghoub

Comments

Popular posts from this blog

سلسلة تعلم برمجة تطبيقات الاندرويد - إعداد بيئة العمل - الحلقة رقم 1

في هذه الحلقة سنقوم بتجهيز بيئة العمل، وإعداد كافة الأدوات والبيئة اللازمة للبدء في برمجة تطبيقات الاندرويد، لنتمكن في الحلقات القادمة من العمل والتطوير باستخدام الأدوات التي سنقوم بإعدادها في هذه الحلقة. 1. للبدء في تطوير أي برنامج على الاندرويد لا بد من توفر حزمة التطوير الأساسية وهي Android SDK . هذه الحزمة هي حجر الأساس لعمل أي تطبيق على الاندرويد حيث تحتوي على مجموعة كبيرة من الوظائف الاساسية والبرامج التي تمكننا من التحدث مع نظام التشغيل الاندرويد، وطلب تنفيذ العمليات والحسابات إلى غيره من الوظائف بحسب طبيعة كل تطبيق ووظائفه. وتمكننا أيضا من إنشاء أجهزة افتراضية Virtual Machines تساعدنا على تجربة التطبيقات حتى بدون وجود جهاز اندرويد  2. حزمة الجافا JDK والتي تقوم بترجمة النص البرمجي لحزمة الاندرويد وكذلك النص البرمجي للتطبيق وتحويله إلى نسخة تنفيذية قابلة للعمل على أي جهاز اندرويد 3. بيئة العمل IDE وفي هذه السلسلة سنقوم باستخدام Netbeans وذلك لسهولة استخدامه وسهولة التطبيق عليه. كما يمكن أيضا استخدام بيئة العمل Eclipse . ولغايات تبسيط هذه الحلقة و...

سلسلة تعلم برمجة تطبيقات الاندرويد – إنشاء أول تطبيق للاندرويد – الحلقة رقم 2

تحدثنا في الحلقة السابقة عن إعداد بيئة العمل، وأهم الأدوات والحزم اللازمة للبدء في تطوير تطبيقات لنظام التشغيل الاندرويد. سنتحدث في هذه الحلقة عن كيفية إنشاء تطبيق للاندرويد، وما هي مكونات تطبيق الاندرويد والبنية الهيكلية ﻷي تطبيق على الاندرويد. إنشاء تطبيق باستخدام بيئة العمل Netbeans : 1. اضغط على قائمة File 2. اختر New Project. 3. اختر نوع المشروع Android 4. اضغط زر Next. 5. اضبط إعدادات المشروع كالتالي: Project Name: اسم المشروع، يفضل أن يكون اسم المشروع هو نفس اسم التطبيق وذلك لتمييزه عن باقي المشاريع الأخرى Package Name: اسم حزمة المشروع، وهنا يجب اتباع قواعد تسمية الحزم في لغة Java إذ يجب أن تتكون من مقطعين على الأقل ويفصل بين كل مقطع بنقطة، ولا يوجد فراغات. Target Platform: رقم نسخة نظام التشغيل الاندرويد التي يدعمها هذا التطبيق، وهنا لا بد من اختيار أقل رقم يتوافق معه هذا التطبيق لمزيد من التفاصيل شاهد الصورة التالية: 6. اضغط على زر Finish وهكذا نكون قد أنشأنا بمساعدة بيئة العمل Netbeans أول تطبيق للأندرويد حيث تم تصميم هيكل التطبيق، واستدعاء كافة ال...

Web Development Best Practices (PHP Best Practices)

Websites development is one of the most challenging projects ever to develop, according to the large number of components you deal with, integrate, and manage in your application. For example, most web projects Deal with databases as their data source, and I ntegrate with external services called web services and APIs. As well the application M anages its own objects and components from views to models to controllers to plugins and so on. A skilled web developer should have a great/deep knowledge in most of components used in his system, and as well should ha ve intensive focus on how each component work and how can be used, what can be done, and what cannot. On the other hand, the huge amount of requirements, components to manage, and time frame given to you to accomplish your mission, and number of people in your team, all these factors together requires from you to organize your tasks, and priorities your requirements, do deep analysis and planning in order to have a hi...