Quantcast CSS Selectors, Properties, and Values | Source and Code System

CSS Selectors, Properties, and Values

Jul 8, 2010  ¦¦  by isr.coder  ¦¦  CSS for Beginner  ¦¦  40 Comments

Whereas HTML has tags, CSS has ‘selectors‘. Selectors are the names given to styles in internal and external style sheets. In this CSS Beginner Tutorial we will be concentrating on HTML selectors, which are simply the names of HTML tags and are used to change the style of a specific tag.

For each selector there are ‘properties‘ inside curly brackets, which simply take the form of words such as color, font-weight or background-color.

A value is given to the property following a colon (NOT an ‘equals’ sign) and semi-colons separate the properties.

 
body {
        font-size: 0.8em;
        color: navy;
}

This will apply the given values to the font-size and color properties to the body selector.

So basically, when this is applied to an HTML document, text between the body tags (which is the content of the whole window) will be 0.8 ems in size and navy in colour.

Lengths and Percentages:

There are many property-specific units for values used in CSS, but there are some general units that are used in a number of properties and it is worth familiarising yourself with these before continuing.

em (such as font-size: 2em) is the unit for the calculated size of a font. So “2em”, for example, is two times the current font size.

px (such as font-size: 12px) is the unit for pixels.

pt (such as font-size: 12pt) is the unit for points.

% (such as font-size: 80%) is the unit for… wait for it… percentages.

Other units include pc (picas), cm (centimetres), mm (millimetres) and in (inches).

When a value is zero, you do not need to state a unit. For example, if you wanted to specify no border, it would be border: 0.

A web page is not a static, absolute medium. It is meant to be flexible and the user should be allowed to view the web page how the hell they like, which includes the font size and the size of the screen.

Because of this, it is generally accepted that ‘em’ or ‘%’ are the best units to use for font-sizes (and possibly even heights and widths, which we shall come across in the CSS Advanced Tutorial), rather than ‘px’, which leads to non-resizable text in most browsers, and should be used sparingly, for border sizes for example.

40 Comments

  • Websites we think you should visit…

    [...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……

  • Sources…

    [...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……

  • Sources…

    [...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……

  • Cool sites…

    [...]we came across a cool site that you might enjoy. Take a look if you want[...]……

  • article marketing…

    [...]while the sites we link to below are completely unrelated to ours, we think they are worth a read, so have a look[...]…

  • Another Website Recommends Your Page…

    [...]I'm wanting tо determine just аѕ much in regards to the online surfing community as I can. Can аnуоne recommend their moѕt favorite blogs, twitter handles, оr sites which yоu find very inde…

  • adult social networking…

    [...]the time to read or visit the content or sites we have linked to below the[...]…

  • TV Lamps…

    The Truth behind Television Replacement Lamps….

  • Found=> Link To Your Post…

    [...]I havе accumulated a number оf thе more significant blogs during my list here[...]…

  • Buy Yankee Candles at Half Off…

    [...]the time to read or visit the content or sites we have linked to below the[...]…

  • Sources…

    [...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……

  • Sources…

    [...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……

  • Great Clips Coupons…

    [...]the following are a handful of listings to websites online I always connect to since we think they will be seriously worth browsing[...]…

  • Found=> Links To Your Site…

    [...]one individuals visitors recently recommended the fоllоwіng website[...]…

  • Tips on how to improve your Blog !…

    [...]here are some links to sites that we link to because we think they are worth visiting[...]…

  • Superb website…

    [...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……

  • Enjoyable Reading…

    We are enjoying the post!…

  • A Star wars Fan Site Mentions You…

    [...]What blogs for political commentary could yоu recommend me to ѕеe?[...]…

  • Websites we think you should visit…

    [...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……

  • Links…

    [...]Sites of interest we have a link to[...]……

  • buy damansara house…

    [...]you will find information that’s relevant to you if you want to buy damansara house[...]…

  • Found=> Recommends Your Site…

    [...]if you wіsh to read a tad bit morе next, i recommend the following[...]…

  • Websites worth visiting…

    [...]here are some links to sites that we link to because we think they are worth visiting[...]……

  • Gems form the internet…

    [...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……

  • Garmin1490t.com…

    [...]we like to honor other sites on the web, even if they aren’t related to us, by linking to them. Below are some sites worth checking out[...]…

  • Check this out…

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

  • Wikia…

    Wika linked to this website…

  • webhosting…

    [...]we like to honor other sites on the web, even if they aren’t related to us, by linking to them. Below are some sites worth checking out[...]…

  • Basketball Drills…

    [...]the time to read or visit the content or sites we have linked to below the[...]…

  • Related websites……

    [...]every once in a while we choose blogs that we read. Allow me to share the newest sites that we choose[...]……

  • Gems form the internet……

    [...]we like to honor many other websites on the net, even if they aren’t associated with us, by linking to them. Under are some webpages worth checking out[...]……

  • Its hard to find good help…

    I am constantnly saying that its hard to get good help, but here is…

  • Ipad Stylus…

    [...]listed below are a couple of hyper-links to internet websites which we connect to for the fact we believe they will be really worth checking out[...]…

  • travel…

    [...]we like to honor other sites on the web, even if they aren’t related to us, by linking to them. Below are some sites worth checking out[...]…

  • Just Browsing…

    While I was surfing today I saw a great post concerning…

  • Creative videos that you must check out !…

    [...]we like to honor other sites on the web, even if they aren’t related to us, by linking to them. Below are some sites worth checking out[...]…

  • Looking around…

    I like to browse around the internet, often I will just go to Digg and follow thru…

  • Finally…

    Great blog posts to look through….

  • Awesome website…

    [...]the time to read or visit the content or sites we have linked to below the[...]……

  • Read was interesting, stay in touch……

    [...]please visit the sites we follow, including this one, as it represents our picks from the web[...]……

Leave a comment

*