Skip to main content

CSS Tutorial – Lesson 1 Part II

In the previous lesson we learned how to define a CSS rule, and we had shown that a CSS rule consists of two parts a selector and a declaration.

In the previous lesson we talked that in the selector we might write the html element we want to style. In our lesson today, completing with CSS rules, we’ll see now other types of selectors,

The ID selector:

CSS allows you to specify a style for a single element, regardless to its tag, depending on its id attribute. as you know, in XHTML each element has an id attribute, and this id must be unique.

To define a CSS rule depending on the ID selector below the syntax for it:

Example:

#theID

{

font-size: 14px;

}

Notes:

  • The above CSS rule will be applied for any element whose id = theID,
  • The ID selector must start with #.

The Class Selector:

Unlike the ID selector, the class selector allows us to define a rule for multiple elements regardless to their tag. The class selector enables us to define a common style for common elements, so that each element whose class same as the selector, will be styled according to the rule it follows.

Example:

.Justifiable

{

text-align:justify;

font-size:12px;

color: black;

}

Notes:

  • The class selector must start with a dot.
  • and used with the class attribute for any element.

In some circumstances, we might need to apply some styles for specific elements, for example for some divs we might need their background-color be the same, with font-size 15px for example, CSS allows us to define specific rules for specific elements, here is the syntax:

Example:

div.Pink

{

background-color: pink;

font-size:15px;

}

Notes:

  • The above rule will be applied for all elements whose class is Pink, so we restricted the rule with the element div, and internally, restricted it to divs whose class is Pink, so this rule cannot work with element p for example though its class might be Pink, only with div element and has a class Pink.

End of this part,

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

Best Wishes,

Anas Jaghoub

Comments

Popular posts from this blog

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

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

XHTML Tutorial–Lesson 1 Part I

Preamble: This tutorial expects that you’ve the basics of HTML 4.01, and supposes that you are familiar with its syntax and purpose. In this tutorial I’ll try to introduce XHTML concept and why we should use XHTML instead of HTML, we’ll talk about differences between HTML and XHTML. We’ll talk about some of web standards that we have to follow when developing a web-based applications. What is XHTML? XHTML stands for EXtensible Hypertext Markup Language, it is almost identical to HTML 4.01, but it is a cleaner version of HTML. We might look to XHTML from a point of view that it is an HTML defined as an XML application. Above all XHTML is recommended by W3C, and though it’s compatible and supported with all web-browsers. XHTML consists of all HTML 4.01 elements combined together with the structure of XML. Why XHTML? The problem of HTML where on no standardization for web browsers, many web browsers around the world, each browser implemented in a way differs from other browsers,...

AABU GTUG Opening Event

On February 17, 2011 We’ve headed to Al Al Bayt University, to run one of the biggest event established there, for opening the AABU GTUG (Google’s Technologies Users Group). The event focused on introducing the GTUGS (Google’s Technologies Users Groups) and introducing Google’s technologies to students, such as Android and App Engine, to Chrome Extensions and HTML5 demos. Attendees exceeded 250 attendee, in addition to Vice president of Al Al Bayt University Dr. Hashem Al Masaeed, Deanship of College of I.T at Al Al Bayt University Prof. Ismail Ababneh, and a quite number of professors and teachers at the college of I.T at AABU, in addition to Yarmuk fm and Al Ro’aya  tv. AABU GTUG as a Google’s Technologies Users Group interested in Google’s technologies and tries as possible to increase students awareness about Google’s technologies, and introduce it to them. Their was a lot of activities during the event, beginning with the key note from me Anas Jaghoub, that included introducin...