Discuss CSS height element question... in the CSS Help forum on Dev Shed. CSS height element question... Cascading Style Sheets (CSS) forum discussing all levels of CSS, including CSS1, CSS2 and CSS Positioning. CSS provides a robust way of applying standardized design concepts to your web pages.
Posts: 104
Time spent in forums: 18 h 33 m 57 sec
Reputation Power: 11
Not quite sure what they were supposed to mean by that but, for example, if you have a header on your page with a background image then you have to set the height of the header area to be as big as the background image in order for it all to display. That is unless the content you put in the header area will stretch the header vertically to show the whole background anyway, but even saying that it is wise to set the height to prevent layout problems due to external influences (change of font size by user for example).
Sounds to me like your college tutor didn't know much about what they were talking about I am afraid.
Posts: 36
Time spent in forums: 15 h 30 m 48 sec
Reputation Power: 66
Ask Why, and then ask why again.
Is applying height used as a replacement for margin or padding?
Is applying a height used to for a specific reason where margin and padding will not work?
example:
On the new wwwdotdevelopersheddotcom
There is a white stripe that runs across the page that contains the developer shed "shed". The white stripe is a div that has a height set to 278px and overflow set to visible. This allows the image of the shed to break out of the the white stripe container. Without a set height the shed would sit inside of it.
Posts: 36
Time spent in forums: 15 h 30 m 48 sec
Reputation Power: 66
Quote:
Originally Posted by simplypixie
Not quite sure what they were supposed to mean by that but, for example, if you have a header on your page with a background image then you have to set the height of the header area to be as big as the background image in order for it all to display. That is unless the content you put in the header area will stretch the header vertically to show the whole background anyway, but even saying that it is wise to set the height to prevent layout problems due to external influences (change of font size by user for example).
Sounds to me like your college tutor didn't know much about what they were talking about I am afraid.
Declaring height is not mandatory for your example. You could use margin and padding.
Posts: 19,830
Time spent in forums: 6 Months 1 Day 16 h 41 m 29 sec
Reputation Power: 4192
Welcome to DevShed Forums, cssbonding.
First off, I should remind you that the correct term is "height property", not "height element".
Quote:
Originally Posted by cssbonding
I was told it is best not to use the height element in college, I don't know if this is because it can conflict with things
I wouldn't say "conflict", but it is best to avoid setting a height on elements that contain text or have descendants that contain text, so that the elements can expand with the content. Remember that users can and (some) will adjust font-sizes to make pages easier to read for themselves. Flexibility is very important in good web design.
Quote:
Originally Posted by simplypixie
for example, if you have a header on your page with a background image then you have to set the height of the header area to be as big as the background image in order for it all to display.
Sounds to me like your college tutor didn't know much about what they were talking about I am afraid.
Sounds to me like you don't know much about what you're talking about. I'm glad that at least one person teaching this in a formal institution knows about that. From the general impression I've gotten, most such instructors don't seem to be aware of many best practices.
Quote:
Originally Posted by Paul-Ninja
Without a set height the shed would sit inside of it.
It would be better if the image was given a negative bottom margin instead. The "height" property is not the only way to force overflow. Absolute and relative positioning can also be used to that kind of thing.
__________________
Spreading knowledge, one newbie at a time. I'm available for hire at Dynamic Site Solutions.
Posts: 104
Time spent in forums: 18 h 33 m 57 sec
Reputation Power: 11
Quote:
Originally Posted by Kravvitz
Sounds to me like you don't know much about what you're talking about. I'm glad that at least one person teaching this in a formal institution knows about that. From the general impression I've gotten, most such instructors don't seem to be aware of many best practices.
I am not sure why you have to reply negatively to every reply I give on this forum and for your information I do know what I am talking about and have been developing using CSS for many years and am always reading up on developments in the language.
If I thought the OP wanted to set a min-height, I would have discussed that with them, but it has a completely different result on the div it is applied to than height which the OP did talk about (as you well know if you know what you are talking about)!
Posts: 54
Time spent in forums: 10 h 47 m 10 sec
Reputation Power: 9
Quote:
Originally Posted by Kravvitz
Welcome to DevShed Forums, cssbonding.
First off, I should remind you that the correct term is "height property", not "height element".
I wouldn't say "conflict", but it is best to avoid setting a height on elements that contain text or have descendants that contain text, so that the elements can expand with the content. Remember that users can and (some) will adjust font-sizes to make pages easier to read for themselves. Flexibility is very important in good web design.
OK, I think the tutor was meaning the wrapper div. It was two years ago, so maybe I was thinking of something else
Posts: 19,830
Time spent in forums: 6 Months 1 Day 16 h 41 m 29 sec
Reputation Power: 4192
Quote:
Originally Posted by simplypixie
I am not sure why you have to reply negatively to every reply I give on this forum and for your information I do know what I am talking about and have been developing using CSS for many years and am always reading up on developments in the language.
For the record, I'm not targeting you specifically. I just will typically respond to anything I feel is incorrect or misleading. In this case you made a sweeping general statement. I will very frequently disagree with those. CSS has a lot of grey areas, so many questions aren't just "yes" or "no".
Knowing the technical things and following widely recognized best practices aren't quite the same. Some sites seem to only focus on the former.
Quote:
Originally Posted by simplypixie
If I thought the OP wanted to set a min-height, I would have discussed that with them, but it has a completely different result on the div it is applied to than height which the OP did talk about (as you well know if you know what you are talking about)!
I was responding to something you said. I did not directly respond to cssbonding's question.
Posts: 4
Time spent in forums: 1 h 11 m 14 sec
Reputation Power: 0
Mozilla, Netscape, and Opera browsers interpret these values as the exact measurements and don't allow a DIV's HEIGHT or WIDTH values to extend beyond what you specify. So if you set the HEIGHT and WIDTH properties for a DIV and then insert images or text that takes up more space, the display will be a jumbled mess.
Internet Explorer is much more forgiving. It considers HEIGHT and WIDTH values to be minimum values and expands the DIV to contain all the content you want - just like a table cell.