css: centreing text in a div tag
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
.pmast_outer {
postiion:relative;
width:100%;
text-align: left;
}
Then you can do what you expect to do
.pmast_insert {
background-color: #CCCCCC;
height: 60px;
width: 468px;
border: 1px solid #FFFF00;
color: #FFFF00;
text-align: right;
float:right;
}
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.
float:right;
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.





