CSS For The Beginner

by 43 replies
50
I'm writing this post because of how often I see people asking questions about or saying that they don't know anything about CSS. I know that to the complete novice CSS looks intimidating but really it's a very simple thing to master. There just aren't that many things to get used to. Hopefully this simple explanation of the basics will be enough to get the beginners up and running. This by no means covers everything related to CSS but it is the basic rules and everything else you can Google and understand how to apply the answers you find on Google.

First a word about tags. Tags, with just a couple of exceptions always have an opening tag and a closing tag. For example a paragraph tag is written like so...





Note the "/" character in the closing tag. This tells the browser that this is the end of the paragraph tag block. Everything between the p tags is treated and rendered as a paragraph. This general rule of opening and closing tags is pretty much universal with all HTML code/markup. Exceptions would be in the case of certain tags that don't actually have any content such as an <img> tag. These tags contain all their information inside the tag itself. For example...



Notice the closing bracket "/>" contains our closing "/" character. This is what's considered a self closing tag. Maybe at another time we will dissect the different components of the tag.

OK, let's move on to the CSS.

CSS stands for Cascading Style Sheet

It is a way to add styling to your page layout and content. There are basically 3 ways to add your styling to your content.

1.) Internal stylesheet. With this method we add the CSS rules to the header of your document using the <style> tag. This would be done like so...
























Now let's say we have one particular h1 tag that we want to be different than every other h1 tag on our site. We can use an inline style on the individual tag and it will override the style that is defined in our stylesheet. Styles applied at the element level are applied before styles that are defined in a stylesheet. So we could make a change to our h1 tag like so...





This will give us an h1 heading that gets all of its styling from our css file except the font-size. The font-size will be applied from the inline style. So this h1 heading will be a blue Tahoma font 50px high instead of 28px high.


Similarities and Differences


In all three of our methods you will notice that styles are defined using the same syntax, a name and a value i.e. In each pair the name is separated from the value by a colon ":" and each name/value pair is closed with a semicolon ";" This syntax is common across each method whether it's an inline style or an external stylesheet.

What is different is the way our styles are packaged. For an inline style we use the "style" attribute which for inline styles is written like so...



This style of notation is used within a tag like so...





You will notice that the style is inside the opening <> brackets and the attribute houses our name/pair elements. But the always uses the same syntax.

Next, in an internal stylesheet we still see the same syntax but we wrap it in "<style>" tags like so...







Lastly we come to the external stylesheet. Again we see the
























In the above example I have defined styles directly for the <p> tags and the <h1> tags. A better way might be to define a class like so...














By using this method when I want to apply this in my HTML document I would simply write my <p> tag like so...





You see in my opening <P> tag I call my class "leftAlignedBlue" and the style that is defined in my CSS file is applied to my paragraph text. Doing it this way I can have several styles defined and apply them whenever or wherever I like.
#website design #beginner #css
  • Very complicated to understand
    • [1] reply
  • Banned
    video tutorial
    youtube /watch?v=6HK81Z7g-mA
  • thank!verry useful for a beginner like me!
  • you can do the same style in other way with in css.

    Suppose you have content div

    #contentdiv{
    write the properties here
    }

    if you need to give the diffrent styles of css with in this content div you can do as below

    #contentdiv p{

    }
  • if you need to understand about the css check the below site


    if you are interested i can make you familiar in all the properties and with in days you can be well know person of css

    Regards,
    Bikshama Reddy.R
  • thanks for this thread...it helped alot.
  • CSS always plays a vital role in web design! CSS is easy to learn and understand...! Thank! Very useful for a beginner like me..!
  • Banned
    [DELETED]
  • The example above is valid code ONLY in XHTML - you need to "close" the tags in this way only in XHTML.

    For 'plain' HTML the correct code is:
    Code:
    <img src="/images/MyPic.gif" alt="alt text goes here">
  • Thanks for this post. =)
  • Banned
    [DELETED]
    • [1] reply
    • I always hated CCS.. it is just boring, but you've explained well here. Will read all the post later
      • [1] reply
  • Banned
    [DELETED]
  • [DELETED]
    • [2] replies


    • Yes it is complicated for a newbie like me but not bad tutorial although lengthy.


    • Yes it is complicated for a newbie like me but not bad tutorial although lengthy.
  • Thanks it's really useful and all beginners including me.
  • Good info for starting CSS.But you could also add youtube video regarding this concept.
  • Complicated to understand at first, but i'll tell you read this over and over and you will learn from this.
  • Hi Ronc0011,
    Thanks for this useful info. I have confusion between class and id. Now I got and will save this link for future reference.
    #myclass
    {
    }
    .myid
    {
    }

    we can use it as...
    <p id="myclass">Content</p>
    <p class="myid">Content</p>

    thanks again to clear these things.
  • thank for sharing, iam very beginer...
  • nice thread...thnx for sharing...
  • Thank You for sharing
  • nice, i always loved css, especially since it was the easiest language for me to learn, good thread.
  • CSS is a advanced scripting language so to learn it first one should make the concept clear of HTML.HTML is a basic language for web designing.
  • What is CSS?

    • CSS stands for Cascading Style Sheets
    • Styles define how to display HTML elements
    • Styles were added to HTML 4.0 to solve a problem
    • External Style Sheets can save a lot of work
    • External Style Sheets are stored in CSS files
    Cegonsoft Dot net training
  • Hello ,

    Nice post and it is very useful to beginners and there more other than this in css as it can be fully made as object oriented they can override and can be inherited etc this will be quite interesting when we move higher to css and styling it using javascript or jQuery
  • A couple of things I would amend and expand upon...

    1. you can use multiple classes on one element, but only one ID. For example:

    PHP Code:
    <class="center blue"
    PHP Code:
    <h2 id="main-heading" class="blue section"
    2. With this in mind: nstead of using a color or design name as a class, use a class name that describes the function of the class instead. It is easier to universally change the class thru CSS than having to edit you HTML later.

    For example, instead of

    PHP Code:
    <class="center blue"
    let's use...

    PHP Code:
    <class="important callout"
    ...then style the class .important with the color:blue. If you want to change "important" elements later to color:red, you can easily change it once in your CSS.

    Style .callout with text-align:center and later it is easier to add a border or background to the class "callout" if you want to change how it is handled..

    This is what is called "semantic CSS". You are naming the classes with the function they perform, rather than the style you are applying.
    .
    .
    .
  • Good stuff mate!

    I would also try W3Schools Online Web Tutorials if you're a noob!
  • Nice tips Thanks for sharing and i think it can be very useful for beginners if they learn here and ask question.
  • Sir,
    can you share with us how to create Drop Down Menu by CSS.
    Many Thanks
  • CSS is a cascading style sheet.CSS if an advanced of HTML.The tag in it is not predefined and one can easily get along with it is he just study on the internet about it.
  • It is my luck that i got a chance to read all.You defined things in very elegant way ! i really like it and understood at first attempt.Do you have a website/blog where i can learn advanced CSS?
  • CSS Beginner Tutorial accepts that we know as much about CSS as we do about the accumulative effects of sea spirt discharge on the brain chemistry of Germanic ammonites. The purpose of this guide is to teach the bare essentials exactly enough to get commenced.
  • Great information! Thanks a lot. I was trying to express something to someone that didn't know anything about CSS and this definitely helped (they aren't a warrior member).
  • [DELETED]
  • for teh beginner - i recommend css teh missing manual - from amazon - amazing book - also teh basic idea css is for styling how html and other code looks - is an important one -

    everything you see is done with css -html teh basic layout and php for making it go round the world with th server - its very easy once the penny drops on fundamentals -

    gd luck
  • I also recommend W3Schools, it's a great free resource. I learned a lot of stuff from there.
  • Nice post and it is very useful to beginners and there more other than this in css as it can be fully made as object oriented they can override and can be inherited etc this will be quite interesting when we move higher to css and styling it using javascript or jQuery
  • very very helpful guide,,,,,,,I read it completely, tried to memorize and kept and back up..................Thank you very very much.....In fact CSS always seems so dangerous that I never tried to read a single line and what I always did is copy pasting but today my last hour gave me such knowledge that i feel flying ..............lalalaaaaallaaaa...
    Thanks Thanks Thanks.....
  • Great info,very useful for a beginner like me!
  • Ok i think this helped me a lot even its complicated.
    Because in coding i did like prefer to learn from video than words and this is what
    a newbie like me thought.
  • Ok i think this helped me a lot even its complicated.
    Because in coding i did like prefer to learn from video than words and this is what
    a newbie like me thought.
  • Thanks for helping me understand some basic stuff
    • [1] reply
    • This seems to be a great tutorial, I'd wish I had something like this when I started. This tutorial was incredibly helpful for CSS beginner. Thanks for making this awesome tutorial.

Next Topics on Trending Feed

  • 50

    I'm writing this post because of how often I see people asking questions about or saying that they don't know anything about CSS. I know that to the complete novice CSS looks intimidating but really it's a very simple thing to master. There just aren't that many things to get used to. Hopefully this simple explanation of the basics will be enough to get the beginners up and running. This by no means covers everything related to CSS but it is the basic rules and everything else you can Google and understand how to apply the answers you find on Google. First a word about tags. Tags, with just a couple of exceptions always have an opening tag and a closing tag. For example a paragraph tag is written like so...