All it does is semantically categorize text.
This might be the most difficult part of coding for websites.
HTML is straightforward.
JavaScript and PHP might be a full coding language, but mostly involves manipulating HTML & CSS.
<header>
<h1>Douglas Thomas</h1>
<!-- SOME STUFF -->
</header>
<div id="main">
<aside>
<p><img src="img/me.jpg" alt="Douglas Thomas"></p>
</aside>
<section>
<h2>My Job</h2>
<!-- SOME STUFF -->
</section>l
<section>
<h2>My Projects</h2>
<!-- SOME STUFF -->
</section>
</div>
link tags are HTML links that are only followed by the browser.
The type attribute tells the browser what kind of file to expect.
<link rel="stylesheet" href="css.css">
</head>
Right-Click on the Remote Site Current Directory pane > Create New File
Call this file css.css.
Right-Click on css.css > View/Edit
Cascading Style Sheet
A file ("sheet") with two main properties:
body {
font-family: Tahoma,sans-serif;
font-size: 18px;
line-height:1.25;
}
body {
}
CSS selectors choose what to style
In this case, we're styling the body element
To overcomplicate it: Specificity
{
font-family:
font-size:
}
There are a TON of CSS Properties. Just like HTML, Google it!
CSS Properties are often set to inherit the parent element's value
{
: Tahoma,sans-serif;
: 18px;
}
Values provide what the CSS will look like.
When you Inspect Element, you can look at possible values
Two kinds of units: Relative & Absolute
I would suggest using relative units as much as possible.
Relative units tend to be valuable for fluid & responsive layouts.
Absolute units are good for lining up strictly with a mockup.
Units calculate into pixels when rendered.
Two kinds of HTML element: Inline & Block
a tagsspan tagsimg tagsdiv, section, header, etc.p tagsh1 to h6Two kinds of HTML element: Inline & Block
display: inlinedisplay: blockdisplay: inline-blockdisplay: griddisplay: tabledisplay: noneBlock means it has a set width and height.
Block can also set margin, padding, and borders.
In display: block, margin, padding & borders substract from the width and height of the element.
I can haslayout?
Add overflow:hidden
In display: block, margin, padding & borders substract from the width and height of the element.
In display: block, margin, padding & borders substract from the width and height of the element.
Note that interior elements can be set to the width of the outer element.
header
header {
width: 80%;
padding: 1em 10%;
background-color: skyblue;
}
Makes the header element full-width (10% + 80% + 10%)
Adds a little top and bottom margins for breathing room - 1em = 18px
sets the skyblue
3 main ways to set color:
black, rebeccapurple, chartreuse
#000000, #663399, #7fff00rgba(0,0,0,1), rgba(102,51,153,1), rgba(127,255,0,1)I use names for unambiguous colors like black and white but almost otherwise always hex.
RGBa is pretty neat because it can set opacity
div#main
div#main {
width: 80%;
padding: 1em 10%;
background-color: lightsteelblue;
}
Almost literally the exact same thing. Patterns are the key to solid CSS design.
Note that the properties are in the same order - this is for organization
header, div#main {
width: 80%;
padding: 1em 10%;
}
header { background-color: skyblue; }
div#main { background-color: lightsteelblue; }
Depends on how you want to organize.
aside
aside {
width: 15%;
margin-right: 5%;
float: left;
clear: left;
}
Sets a width and margin-right totaling 20% of parent element
floats the aside left.
Makes sure there is no content to the left of the aside, i.e. it is clear.
float & clearA float is a box that is shifted to the left or right on the current line. The most interesting characteristic of a float (or “floated” or “floating” box) is that content may flow along its side (or be prohibited from doing so by the “clear” property). Content flows down the right side of a left-floated box and down the left side of a right-floated box.
Sort of like pressing Text Wrapping > Square in Word.
clear moves a floated element past another floated element. This allows elements to stack.
Would you like to know more? More than you'd want to know.
aside img {
width: 100%;
}
You might have noticed your image going way outside your column.
By setting the image's width to 100%, you make sure that it only fills in inside of your parent element.
We add this right below the aside to keep things organized by section.
float the section
section {
width: 80%;
float: right;
clear: right;
}
We set the sections to 80% width - (100%-15%-5%) to take into account the left aside.
To clean up the margins, we float the section elements right.
Since there's nothing to the right, the clear doesn't do much, but it in two-column layout, this makes sure nothing goes awry.
float Breaks Stuff
div#main {
width: 80%;
padding: 1em 10%;
background-color: lightsteelblue;
overflow: hidden;
}
Float does some odd things. The first is that it collapses parent elements to make sure text-wrapping acts correctly.
It's often necessary to make a small edit to the parent element to make it work.
The dirtiest solution is adding overflow: hidden.
a:hover {
text-decoration:underline overline;
}
Lots of elements take "pseudoclasses" like target, hover, before, etc.
These are a little inconsistent, but overall work well across browsers.
body
body {
font-family:Tahoma,sans-serif;
font-size: 18px;
line-height:1.25;
margin:0;
padding:0;
}
Every element has a "user-agent-style" that a browser adds on.
In most cases, it adds a little margin to the body element.
Even though we didn't set it, we have to remove it.
Another example of this is a blue border around image links in Internet Explorer.
@media (max-width:600px) {
body { font-size: 16px; }
header, div#main {
width:90%;
padding: 1em 5%;
}
aside, section {
width:100%;
}
}
This is the key to "Responsive" and "Adaptive" design: the screen changes, so we change how the content flows.
@media Query
@media (max-width:600px) {
}
The @media query only fires if the screen is less than 600px. Above that it doesn't happen.
To maintain the Cascade, it's easier to place this as the end of the file
@media Query
body { font-size: 16px; }
header, div#main {
width:90%;
padding: 1em 5%;
}
aside, section {
width:100%;
}
Otherwise, it's just normal CSS
Have some fun with this page.
Change the colors - to change text, you can use color on any element.
Add elements you think are relevant. Add images and links.