Friday, February 17, 2012

CSS Basics - Applying CSS to HTML - Inline Styles


There are three ways you can apply CSS to a HTML document.
  • Inline Styles
  • Embedded Styles
  • External Stylesheets
You should know that you should always use the third one unless you have special reasons for using the first two. You'll come to know why is that but before going on to that, let us review the three options.

Inline Styles

Using a style attribute, you can apply styles to an element as given below:

<p style="background:blue; color:white; padding:5px;">Paragraph</p >

Withing this attribute, you list all CSS properties and their values. Here, each property or value pair is separated by a semi-colon from the others and each property is separated by a colon from its value within each pair.

This is how you define styles in CSS.

There is one benefit of the Inline Styles and that is the browser will be constrained to use these settings. Any other styles defined in other style sheets or those which are embedded in the head of the document will be overridden by Inline Styles.

However, this one comes with problems too. Its one big problem is that they make maintenance harder than they should be. In addition to the maintenance issue, Inline Styles doesn't take the advantage of the most coercive part of CSS, the Cascade. Cascade is something which when used defines the look and feel of a web page and the browser applies it to all elements matching a certain rule.

The other two ways will be discussed in the next post. Meanwhile browse the blog for topics like Android Application Development and web application development

2 comments:

John Mann said...

Substantially the article is really the best on this laudable topic. I concur with your conclusions and will eagerly look forward to your future updates.Just saying thank you will not just be enough for the wonderful lucidity in your writing. free cell phone

serviced apartments bangalore said...

Princess Square in Koramangala - Serviced Apartments in Bangalore

With over 40 years of experience in the Service Industry all of us at princess square Service Apartments personally know caring for the guest and It is our goal to make sure you, your family and friends the guest enjoy a carefree vacation or Superior business class experience.

We have a small quality driven collection of hotels & hotel apartments within one of the world's most modern and fastest growing city of Bangalore.

Welcome to the Garden city - Welcome to Princess square Service Apartments Hospitality, where our promise of pure value, pure quality and pure service is delivered.

An essential attribute of all our properties are our convenience and central locations within the city of Bangalore.

At princess square Service Apartments we provide a wonderful choice. Whether you are a discerning budget traveler or just looking for that element of luxury of a 5 star business hotel, we have the accommodation solution to suite you.

Our deluxe hotel apartments offer a choice of both full hotel service operations as well as self catering facilities. We have an extensive choice of accommodations to choose from and our portfolio includes standard hotel rooms, deluxe hotel suites, studios, One, Two & Three Bedroom suite apartments, Royal Suites, Executive & Privilege Floors.

We are ideal for leisure, corporate travelers, stopovers & long stays.

All our hospitality establishments provide only the highest levels of comfortable quality accommodations and we are the perfect choice for your next city break, business meeting or special family occasion.

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | JCPenney Coupons