Dr. Greg Bernstein
Updated September 12th, 2021
display
propertyfloat
property for its intended purposeInvisible CSS. Good review and in depth look at important CSS concepts.
From MDN:
CSS page layout techniques allow us to take elements contained in a web page and control where they are positioned relative to their default position in normal layout flow, the other elements around them, their parent container, or the main viewport/window.
From MDN:
The elements that appear one below the other are described as block elements, in contrast to inline elements, which appear one beside the other, like the individual words in a paragraph.
Normal flow is how the browser lays out HTML pages by default when you do nothing to control page layout.
HTML is displayed in the exact order in which it appears in the source code, with elements stacked up on top of one another
We’ll use three CSS properties to change the “normal flow”: float
, position
, and display
.
How long have grids been used in page layout?
<table>
element was created for the tabular display of data.display
Propertydisplay
From display
The display CSS property specifies the type of rendering box used for an element. In HTML, default display property values are taken from behaviors described in the HTML specifications or from the browser/user default stylesheet.
We can use the display
property to change the defined layout of an element
block
– Forces “block” layout, one item over anotherinline
– Forces “inline” layout, one item next to anotherinline-block
– a combination that respects widthsdisplay
display: flex;
for FlexBox layout within this element (container)display: grid;
for Grid layout within this element (container)flex
and grid
have many, many additional properties that can be set on both container and contained elements.display: none
From MDN:
In addition to the many different display box types, the value none lets you turn off the display of an element; when you use none, all descendant elements also have their display turned off.
Originally, the float property was introduced to allow web developers to implement simple layouts involving an image floating inside a column of text, with the text wrapping around the left or right of it.
<style>#Foil {width:40%; float:left}</style>
<img src="MikePercyFoiling.jpg" id="Foil" >
<p>Foiling is the newest and greating thing to hit sailing...</p>
Foiling is the newest and greating thing to hit sailing. Everyone is doing it! Yes, kiters (kite boarders), windsurfers, Americas cup yachts, and even your Professor.
The element with the float set on it is taken out of the normal layout flow of the document and stuck to the left (we set float:left
) hand side of its parent container.
Any content that comes after the floated element in the normal layout flow will now wrap around it, filling up the space to the right hand side of it as far up as the top of the floated element.
File: FloatPractice.html