PLEASE can anyone help with a CSS query. In my masthead I want to use absolute positioning to position different images and menu options ABSOLUTELY within the MASTHEAD rather than within the BODY - at the moment things are positioned absolutely within the body not within the masthead. I've tried setting a div container which is relatively positioned (div id="mastheadsection") to act as a parent for all the images, but they still end up being positioned absolutely for the body rather than the masthead. My code is: My css code is: Would be grateful for any help - I've read quite a bit and don't know where I'm going wrong.
You can remove the coords from mastheadsection. You can relatively position someone and you don't need to state coords; the default is 0, 0 anyway. *edit there are two problems: There is no space between your class and your alt attribute in the last two images, and you're using the wrong selector in the CSS. class="imgattractive"alt=""... adding in a space may help, as most browsers rely on the spaces as much as the "" to determine where one attribute ends and another starts. Second, you are using a class selector (.mastheadsection) when the HTML is using an id. There is no element on your page who matches .mastheadsection you need #mastheadsection Third, you can simplify your CSS: #mastheadsection { position:relative; width: 950px; height: 500px; } #mastheadsection img { position: absolute; } .imglogo { /*this isn't even necessarily needed since 0, 0 is the default*/ top:0px; left:0px; } .imgattractive { top:100px; left:110px; } .imgseo { top:130px; left:200px; } Code (markup): btw if these images are showing text, that is the text you must set in your alt="" Such as class="imglogo" alt="Joe's Garage" you don't need to say "logo of joe's garage" though. Just know if someone visits your page and the images don't load for whatever reason, that there is text saying the same thing the images are saying.
Many thanks Stomme poes - I've been trying to hack my way into css for a while now, but your explanation has just clarified a few things for me. And the code is now working too!! I've added a big plus to your reputation!!