1pagedesign.com.au – web design

bloggin on web design and interesting things we find on the way…

XHTML and CSS for absolute nubes…

Hi, it’s me Edmundo again – back as I promised with more on XHTML and CSS for beginners – yesterday we covered simply what these two words mean and if you remember most of what we went over took us back to the pre-internet print days.

Today and tomorrow we are going to talk about tags or elements within XHTML and then about attributes and then I’m going to point you in the right direction for a great book that would provide further study and reference for XHTML and CSS (and even a little Java Script).

The point of mark-up or eXtensible Hypertext Markup Language, as you will remember, is to mark up regular text so that a browser can render it on screen in the way you – the marker upperer (ok, there has to be a better name for you – get back to me) – intends. Tags within the mark up are recognised by XHTML and ignored in regards to “printing” them to the screen – but read and understood with regards to everything that sits between the beginning Tag and the ending Tag. Thus all included text or information between the two tags can be delivered as intended.

Let’s use the example of a header. In XHTML there are 6 levels of header. They are denoted by the letter “h” and a number which will specify if they are the highest/largest type of header “h1″ or the last/smallest type of header “h6″.

To indicate that they are Tags and not just the letter h plus a number (how else would you present a document on XHTML headers?) the are encased in less thanĀ  “< ” and greater than “>” chevrons. Finally to distinguish the opening Tag from the closing Tag we give the closing Tag a slash “</ ” to tell the browser that it can stop rendering text in this fashion for now.

So to mark up a header we would write the XHTML as follows: <h1> My Header </h1> – this would render as My Header in the appropriate font size and weight in the chosen browser.

Q. would all browsers render this XHTML the same way? A. of course not – XHTML and CSS would be way too easy to use if all the browser makers treated the instructions the same way. To make things MUCH more interesting – everyone does everything differently. Ha, I feel like a pro that I know such amazing things on only my second day! I was born to do this.

P.S. at the basic level the differences are minimal and there is absolutely no need for concern – it’s just minor presentation points.

Other common Tags and their meanings follow:

<html></html> Everything between these tags is the html document itself.

<head></head> Everything between these tags belong to the header of the document (not displayed)

<title></title> Everything here displays as the title at the top of the browser window and not in the document itself.

<body></body> Everything here displays as the main document – this is the lowest level of the document mark-up for display purposes.

<p></p> Everything between these symbols is treated as a paragraph

<ul></ul>Everything between these symbols is treated as a list (unordered in this case – meaning no numbers to mark the list).

<li></li> Everything between this mark up is a line within the list – e.g. in a shopping list this might be bread or milk etc.

<h1></h1> and back to our first friend the “header” mark up. Everything between these tags would be the highest (largest) form of header – perhaps to start your document.

Note how everything is lowercase – this is ALWAYS the case for tags/elements in XHTML. You will get errors if you use caps.

Tomorrow we’ll look at attributes – but I’ll leave you with one last bit of info. that is quite cool. Sometimes we don’t need to include any text between the Tags or element, because for instance that element does not render any text.

An example would be <br />. This is the break tag and it breaks a sentence to a new line at the point that you include it in the document. Since it performs a function but does not contain anything – it can self close! Cool huh? In the old days (HTML) self closing was not required – one just used the opening tag and that was good enough – but in moving to XHTML (a stricter version of mark-up) elements (tags – same thing) need to self close – and that’s how they do it.

See you tomorrow for attributes – P.S. Edmundo loves his new job – it’s so interesting!

Edmundo’s first day with 1pagedesign – beginning to understand the web.

…and what a first day. I’ve learned so much and – as promised – I’m using my spare time in the evening to share it with you. I don’t have a loyal or happy community just yet, but hey – that’ll come.

As you know I’m a newbie to being a newbie – that means (as my uncle Manuel used to say to his employer Mr. Basil Fawlty) “I know naaaa-ting”! Actually I know less than him, because Uncle Manuel knew a lot about all sorts of things – he just couldn’t remember much when Mr. Fawlty kept hitting him hard on the head with the back of a spoon.

So, the two main topics I came into contact with today were XHTML and CSS. It’s clear that these form the backbone of my initial learning. They are exciting concepts actually and not very hard to grasp either. XHTML stands for eXtensible Hypertext Mark up Language. Mark-up comes from the old days when sub-editors would mark up “copy” so that the printers would know how to set up the presses to render the pages as required. In fact much of what I am about to learn in this first phase (XHTML and CSS) is very clearly based on the printing business.

When you open a browser (Internet Explorer, FireFox etc.) you are asking the browser to render a “marked up” document to your screen according to the instructions of the author. That document is a simple text document with the file extension .html or .htm to which has been added some “mark-up” telling the browser where to place certain things and how to display them.

The other component I mentioned, CSS, stands for Cascading Style Sheets. True to it’s name it “styles” the document – so applies formatting styles. The “cascading” part comes from the idea (and fact) that a style set at a top level will “cascade” down through the different levels of the document – so for example – if at the top level I tell the browser that I want to use a Sans Serif font it will apply that request all the way through the document until I ask it to treat a portion of the document differently – hence it cascades. Cool or what?

CSS style instructions can either reside in the document (I’ll tell you how later) or can sit in another file (simple text doc) with a .CSS extension and be called by the XHTML document. The second way is most common these days – at least amongst the pros – because it allows all the different “styling” instructions to be located in one central easy to manage place.

OK – that’s all you get today – tomorrow I pick up on XHTML tags and how they indicate the structure of your document.