banner
Welcome to HTML.co.uk, the number one resource for all news, information, and happenings regarding HTML.

Updates: HTML.co.uk has just been relaunched. Subscribe to our RSS Feed to stay on top of HTML news and techniques.
Aug
14th

Using CSS (Cascading Style Sheets): Where to Start

For you to store style information there are three places. For all the three places, the syntax will be the same but for the sake of clarity, here we are going to discuss the styles that are placed in of the document.

Rules

1.The entire style information must be stored within the </style> and <style> element. By doing so, browser will come to know that the information stored is for styles.
2.you have to include type attributes always
This attributes will indicate what type of style rules you are going to use. The style that is commonly used is CSS but other than CSS, there are other types as wee such as (JSS, XSL and many others).
3.In the comment tags, enclose all the style rules

By doing so, it ensures you that the older browsers even by mistake will not display style rules.

Mainly, the style rule is comprised of 2 things, the declaration and selector.

Declaration – this is a specific style call that will be helpful to affect the selector

Selector – this HTML element is the one that will be very much affected by the rule.

The syntax for the style rule will be ‘selector {property: value ;}’

So, in order to set all the bold text into red, you can write ‘b {colour: red ;}’

The thing that makes the usage of CSS very easy is that you will be able to group the components together that you like to have the similar style. Take for example: if you want all the H1, H2 and the entire bold text in red, you can write

‘b {colour: red ;}’
‘h1 {colour: red;}’
‘h2 {colour: red;}’

however, with the help of grouping, you will be able to put all of them on the same line.
‘b, h1, h2 {colour: red;}’
you can even group the rule together. Take for example, in order to make all the h3 text blue and font in Arial, you can write
You can also group together rules (separated by a semi-colon (;) ). For example, to make all h3 text blue and Arial fonts, you would write:

‘h3 {
font-family: Arial;
colour: blue;
}’
Just for convention, we can put all the rules in separate line but it is not very much required.

Some Common Styles
There are different font attributes that are used commonly.
Font family – this specifies the font face that to be used.
Font-size – it will specify the text size.
Font-style – it will specify whether the text will be displayed in normal, oblique or italic.
Font variant – it will specify whether the text to be displayed in normal or small caps.
Font-weight – it will specify how dark or light the text will be
The other style that is commonly used is the ‘text-decoration’. Along with this tag, you will be able to remove underlines from various links, put the lines through the marked out text or else can make the text blink.


Apr
29th

Detailed Guide to Building an External Style Sheet

Advantages and disadvantages of using the external style sheets
The finest things that cane be done using this Cascading Style Sheets is that it would help you to keep your site in consistent. The simplest way to keep the site in consistent is to import an External Style Sheet or link the site. If the same external style sheet is used for each and every page of the site, it is sure that all the fonts of the site will be same.

Advantages of using the External Style Sheets
At once you can control the feel and also the look of many documents.
If you work with a team of people to create a Website, especially the External sheets is very much useful. Several style rules is pretty difficult to bear in mind and if you might taken a printed style guide and it is tedious and inefficient to be continuously go on flipping through out in order to determine if at all a example text has to be written in 14 point courier and 10 point Arial font.
You can even create classes of more styles that can be used on with various HTML elements as well.
If you want your fonts to be more efficient, you can easily group it.
All of the grouping methods that are used in CSS also can be used in this External Style Sheets as well and also this even provides you more flexibility with on your pages.

Disadvantages of using External Style Sheets:
If these External style sheets are very large, the download time will be increased.
They can increase the proximity of the site if there are small numbers of font styles.
These External style sheets get larger pretty quickly as it’s very hard to tell whether and when a style is no longer in use as it is deleted when the page s shut down or closed.

Creating an External Style Sheet
These External style sheets are produced or generated with a related syntax to the document level style sheets. Though all of the things that you need to include are the declaration and selector the syntax for the rule is and it is just like the document
Selector (property: value ;}
This rue has to be saved into a text file along with the extension of .css. Actually this is not required, but having this habit is good. By using this, you will be able to immediately recognize your style sheets.
You can link the style sheet documents in 2 different ways.

Linking
to link a style sheet document, use the HTML tag

Importing
Within the document level of style sheet, you can import the style sheet and with this you can import any URL and continue the style attributes of the External Style Sheet even without losing any document.