Hi everyone, I just grabbed myself some tutorials on HTML and CSS, and attached to this post is the very first page I hand-coded. Even though they’re valid xhtml strict, css 2.1 and do not use table at all, I think there’s something about my coding that’s quite not right according to the standard.
There are a few things i see that can be improved upon…
You have a DIV element with the id of header then inside that you have another DIV element with the id of logo and inside that the h1 element, to cut down on markup and CSS what you can do is remove the #logo element and just have the H1 element with the bottom margin of 5px.
Your #header element contains an unordered list which has a property of float: left, because your not floating anything before or after the UL element you don’t need the float property. Also on your #header element you will need to add a clear fix to it such as overflow: hidden or visit the following link for my personal preference. CSS clearfix
Currently your #horz_advert and #action elements are DIV’s, they can either be a paragraph or span tag instead or just the IMG tag by itself with an id.
I think that’s pretty much from me as far as i could see, good job bud as you certainly got the know how to continue as a front end web developer.
I think there’s something not right about my css. Since after browsing around here looking at people’s codes, they use a lot of different kinds of rules (some of them I don’t even know about, had to do a check) for their works, not just simple margin-padding-floating like I did.
Regarding that paticular case, because there’s a line between the two paragraphs intro and summary that I had to put them in separate divisions and use a bottom/top border. Is there a better way to do it?
Thanks again for your help
PS: This post is directed at ralph.m since SgtLegend posted when I’m in the middle of typing
You could just put the line on the paragraph itself, adding bottom margin and padding as necessary. You could either give that P a special class, or even try something like
I actually found a JS script that emulates CSS3 pseudo selectors in IE 8 and below and older modern browsers, i have personally used it and love it but in rare cases some scripts conflict with but 99% of the time you can get great results.
The main UL element doesn’t need to be float as by default it follows the flow of the page, for your LI elements however you can use the display property with a value of inline-block which works in all browsers except IE 6 & 7 which require just inline as the value. The main issue with floats is unless you clear them the flow of the page can become a real mess and a nightmare to fix which is why i suggested you either use the overflow or .clearfix methods to clear the floats in your navigation.
If you don’t want to end up writing IE specific CSS then float is the way to go but personally i try to avoid floats as i still try to include the IE 6 audience to sites i build.