|
|
|
|
Thread title: Discuss the use of html elements |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
06-04-2008, 02:08 PM
|
#1
|
Status: I'm new around here
Join date: Jun 2006
Location:
Expertise:
Software:
Posts: 15
|
Discuss the use of html elements
Hey!
I've seen many people do some crazy coding(bad) and I don't know if I am doing wrong or they sometimes because it's so many that do the same.
An example:
PHP Code:
<div id="menu"> <ul> <li>Test</li> <li>Test2</li> </ul> </div>
Why not just write
PHP Code:
<ul id="menu"> <li>Test</li> <li>Test2</li> </ul>
And many people use javascript + pictures for :hover that easy could have been fixed in css only and they call themself professional.
So what are professional these days when I see of 60% are doing like these examples and there are more but I can start with these.
Best regards,
Marcus
|
|
06-04-2008, 05:01 PM
|
#2
|
Status: HTML & CSS Guru
Join date: Mar 2005
Location: Ghent, Belgium
Expertise: HTML, CSS
Software:
Posts: 1,226
|
I'm afraid it's something that's not easy to root out: people are forced to use div's so they use it for anything they can think off...
The Javascript thing is from the DreamWeaver era, which created that Javascript code.
Unfortunately, there's not much you can do about it... For a novice html user, this will look like normal and good code; of course, if you know what you're doing, you realise there are better ways to handle this.
The same goes for the whole valid xHTML & CSS... It's irrelevant wether it's valid or not, it has to be structured properly aswell.
|
|
06-04-2008, 05:27 PM
|
#3
|
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
Posts: 5,200
|
One reason, which usually isn't a valid excuse, for the first code is when they need two containers around the list items. This could be when they need a rounded-edge container that fits to exactly needed width (left image on div, right image on ul). But I think it's safe to say that only 0.1% of people using that code do that.
|
|
06-04-2008, 10:11 PM
|
#4
|
Status: Member
Join date: Oct 2006
Location: Australia
Expertise:
Software:
Posts: 297
|
Sometimes you need a div around a menu for background effects. Mostly though, its just bad coding.
Why do all these "pros" do half the rubbish they do?
You are doing it right.
|
|
06-04-2008, 10:47 PM
|
#5
|
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
Posts: 4,449
|
Originally Posted by rochow
Sometimes you need a div around a menu for background effects. Mostly though, its just bad coding.
Why do all these "pros" do half the rubbish they do?
You are doing it right.
|
Negative, all those effects can be done via the UL.
|
|
06-04-2008, 11:04 PM
|
#6
|
Status: I'm new around here
Join date: Jun 2006
Location:
Expertise:
Software:
Posts: 15
|
Nice to get some response, we can take another example.
I'v seen ppl adding this to their site to center their page.
Example
Code:
<div align="center">
<div id="container"></div>
</div>
Please learn to use margin :=)
I blacklist alot of tags like <span><b><i><u><font> . if I find any of these tags in a code I think its noobish... Anyone feel the same?
|
|
06-04-2008, 11:05 PM
|
#7
|
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
Posts: 5,200
|
Wow, from looking at your site, rochow, you are one ****ing arrogant person. Especially from reading your HTML comments (Q&A). How you get any clients at all is beyond me. Also, in your code, I can see a bunch of unnecessary tags, empty ones, etc. so I don't see why you call yourself 'the best'.
vaLhak: You are wrong about span, in my opinion. There are several places where it is acceptable.
|
|
06-04-2008, 11:29 PM
|
#8
|
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
Posts: 3,820
|
From experience it appears that the 'bad habits' that people pick up with regards to coding HTML documents stems from not appreciating what the markup is all about.
Coming at the HTML from the viewpoint of having a design and making that into a web page lends itself to getting things done via shortcuts (or longcuts!), incorrect tags, structures and patterns, etc. simply to achieve the visual effect intended.
I also think that the whole self-learning aspect through which many people learned to code (myself included) lends itself to picking up habits (good or bad) and sticking with them because they 'just work'.
|
|
06-05-2008, 12:01 AM
|
#9
|
Status: Pastafarian
Join date: May 2006
Location: Duct Taped to your Ceiling
Expertise:
Software:
Posts: 3,440
|
There are many situations where you may need/want to wrap the UL in it's own div. This can be related to JS, backgrounds, browser issues,
Originally Posted by Jeff Andersen
Negative, all those effects can be done via the UL.
|
That's not really the case. Suppose you need two images (multiple backgrounds has very limited support), or the UL needs to be floated to the right? Or the UL needs a z-index but is absolutely positioned - in this case you'd need the div to apply correct z-indexing to ie6 which ignores z-index on an absolutely positioned element so the z-index must be applied to the parent (in this case the div).
There are always rules, exceptions, and rules with exceptions for the exceptions
|
|
06-05-2008, 12:17 AM
|
#10
|
Status: Member
Join date: Oct 2006
Location: Australia
Expertise:
Software:
Posts: 297
|
Originally Posted by Jeff Andersen
Negative, all those effects can be done via the UL.
|
No, they can't.
I have had many instances where 2 background images were required - 1 got slapped on the <ul> and 1 got put on the <div>
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|