Height of divs
In a CSS style sheet its common to center the content by having a div with an id styled like
#outer
{
position: relative;
width: 400px;
margin: auto;
background-color: rgb(1,0,104);
border: 5px white solid;
}
which is 400 wide and centered. But what height? You can fix the height, but if you want it to work with any content, there is an ‘issue’. By default a div goes ‘height:auto;’, and expands to enclose its content. This works – sort of. Suppose the html is
<div id=”outer”>
blah blah blah
blah blah</div>
then you see:

so the outer div has expanded. Now suppose you put another div inside the outer div:
<div id=”outer”>
<div id=”title”>The title<br/>on two lines</div>
blah blah blah
blah blah
</div>
and title is styled
#title
{
border: thin red solid;
}
then we see:

still correct. Now suppose we position title absolute, like this:
#title
{
position: absolute;
top:20px;
left:50px;
border: thin red solid;
}
Now we see:

The browser is not clever enough to work out what height it would need to be to enclose the inner div – it has given up. So you can’t use absolute positioning if you want the containing div to work out its correct height.
If you use relative positioning – the containing div height is correct, according to the ‘initial’ position of the inner div, before its moved, as it were. For example, if you had
#title
{
position: relative;
top:20px;
left:50px;
border: thin red solid;
}
you see:

The browser has left room for it in its initial position, above the ‘blah blah’.
So this is OK for left-right positioning. What if we want it not at the top? Set a margin-top:
#title
{
position: relative;
top:0px;
left:50px;
width: 100px;
margin-top:50px;
border: thin red solid;
}
and you get:

This took me all afternoon. Ha!
My pretty pastel website
I’ve hardly touched my website for around a year, but I’m currently preparing to teach a week-long course on HTML, CSS, JavaScript, SQL and PHP (pretty good in a week) so I thought I should practice what I preach. Which I can’t, really, because I’m visually pretty uncreative. But I know how to Google, and I found this excellent color scheme gismo, and this piece about web fonts, and the result is this. What do you think?







