Think of HTML like the structure of a house. There is a foundation, walls, doors and windows.
<div></div>
<span></span>
<img />
<nav></nav>
<section></section>
<footer></footer>
<ul></ul>
<li></li>
Semantic Element
Semantic Element
Semantic Element
<p></p>
<h1></h1>
<a></a>
<li></li>
<ol></ol>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<nav>
<span class="company-name">Company</span>
<ul>
<li>
<a href="">Home</a>
<a href="">About</a>
<a href="">Contact</a>
</li>
</ul>
</nav>
<section>
<div class="hero"></div>
</section>
<section class="image-container">
<img src="link to image" alt="description of image">
<img src="link to image" alt="description of image">
</section>
<footer></footer>
</body>
</html>
Lets break it down
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
</html>
<!DOCTYPE html>
Lets the browser know what kind of document is being served.
<html></html>
The outer most element. Everything lives inside of it
<head></head>
Where the brains of our project live. Specific information about the site will be stored here
<body>
<nav>
<span class="company-name">Company</span>
<ul>
<li>
<a href="">Home</a>
<a href="">About</a>
<a href="">Contact</a>
</li>
</ul>
</nav>
<section>
<div class="hero"></div>
</section>
<section class="image-container">
<img src="link to image" alt="description of image">
<img src="link to image" alt="description of image">
</section>
<footer></footer>
</body>
<body></body>
Where the magic happens. This is the "foundation" and where we will put our "walls, doors and windows". The body element is a sibling to the <head> element, inside of the <html> element
CSS is the color of our house, the size of the windows and position/color of the door.
Classes -> .class-name
IDs -> #id-name
Elements -> elementName
.hero {
/* Properties go here */
}
#btn {
/* Properties go here */
}
button {
/* Properties go here */
}
Some common ways to select your HTML
Cascading: CSS flows from the top of the file down. If there is a conflicting selector lower in the file, it will apply that styling UNLESS...
Specificity: CSS follows a specificity, or weighting system. Some selectors carry more weight, meaning they will be applied over lesser selectors, even if they are below the heavier selector
The higher the weight, the more specific that selector is. The more specific style always wins regardless of order.
height
width
color
font-family
background-color
padding
margin
z-index
position
display
font-weight
border
Content