css: centreing text in a div tag
HTML design should be easier, with CSS. But sometimes it isn’t. So this is a reminder for me, and if you find it useful too, then that’s a bonus
They go and just depreciate old standards like right align.
CSS styles are easy and can be applied to any Tag. Thus;
(PS zero thanks to WordPress for rendering code inside code tags meaning I needed a screen grab picture instead)
But when it comes to centreing elements within elements, it goes a bit to pot.
The simple answer is you need a container FIRST which is somewhere
Then you can do what you expect to do
border: 1px solid #FFFF00;
and then you simply tie the two together in divs using classes. thus;
I don’t know why no one else can seem to explain it that easily?
I had to read 12 different design tutorials and still try empirically.
was the remaining missing piece of my alignment nightmare.
Anyway there we go…
If you don’t put the master container somewhere (ie relative) then it just doesn’t work.