I'm learning css. Can anyone please tell me the impotence of using CSS positioning? I can design web pages without positioning. Then why should I use this messy thing? Is there any problem if I don't use this?
I use to think as you do. Then I watched a video here on css tricks about positioning and had my "Ah ha!" moment. There are many reasons to use positioning. One of which would be drop down menu's. Another good reason would be to have one element sit over another. The list gets pretty long. In the beginning, I didn't use a bunch of relative or absolute positioning, but as mys skills grew and the websites became more complicated in structure. I found that there was a good reason to use it.
If you don't need it, nobody says you have to use it.
However, if you are saying you don't need it because you are using javascript to handle positioning then you might want to reconsider. For maintainability and readability it is good to keep your styles, markup and functionality separate. If this is the case, a quick search on MVC in web development should help you figure out why this is important.
Otherwise, you do not have to use it. But if you are learning, you should give it a try.
Thanks for your nice answer. I didn't work with drop-down menu. So I can't speak about it. But I can place element sit beside one to another by floating and simply margin and padding. Isn't it?
In fact, I used floating, margin and padding to place an element in right place. I didn't mean I'll not use it. I just wanted to get the point that when and why use the positioning when I can do it with floating, margin and padding. Thanks for your replay.
I think you need a better understanding of positioning. You're using it whether you know it or not. I'm guessing you're referring to absolute positioning, but keep in mind there's static, relative, fixed, and absolute (and inherit, but that will be one of the others). The default of course is static, but they each have their place.
@anika039 I see what you're saying, but along the way you will come across situations where positioning is the best option. For example:
- putting something in the absolute center of the page - having something always on the same position on the screen, no matter how much you scroll - placing an element "over" or "on top" of another element, as if they are layered - etc. etc.
I understand your reservations but that's just it -- it's hard to explain why you should use it, and you'll really get that "a-HA!" moment at one point when you come across a situation where positioning will be very helpful.
Bottom line: do what works. But, in my opinion, it is always, always, always recommended to know as much as you can about the different properties in CSS.
Thanks in Advance
Anika
http://css-tricks.com/video-screencasts/110-quick-overview-of-css-position-values/
http://css-tricks.com/absolute-positioning-inside-relative-positioning/
You should work to learn the positioning and make sure you understand it. It will make your life easier
However, if you are saying you don't need it because you are using javascript to handle positioning then you might want to reconsider. For maintainability and readability it is good to keep your styles, markup and functionality separate. If this is the case, a quick search on MVC in web development should help you figure out why this is important.
Otherwise, you do not have to use it. But if you are learning, you should give it a try.
Thanks for your nice answer. I didn't work with drop-down menu. So I can't speak about it. But I can place element sit beside one to another by floating and simply margin and padding. Isn't it?
In fact, I used floating, margin and padding to place an element in right place. I didn't mean I'll not use it. I just wanted to get the point that when and why use the positioning when I can do it with floating, margin and padding. Thanks for your replay.
- putting something in the absolute center of the page
- having something always on the same position on the screen, no matter how much you scroll
- placing an element "over" or "on top" of another element, as if they are layered
- etc. etc.
I understand your reservations but that's just it -- it's hard to explain why you should use it, and you'll really get that "a-HA!" moment at one point when you come across a situation where positioning will be very helpful.
Thanks all of you. I need to study and practice more with all positioning. Special thanks to Senff for making some good points to using positioning.
Bottom line: do what works. But, in my opinion, it is always, always, always recommended to know as much as you can about the different properties in CSS.