CodePamoja
CodePamoja means "Code Together" in Swahili. We are a group of passionate developers in The Netherlands and Kenya working together in virtual teams, transferring the latest software development skills to each other.
<p class="basic-text">This is a Paragraph</p>
<ul class="mylist">
<li class="list-item">Item one</li>
<li class="list-item">Item two</li>
<li class="list-item">Item three</li>
<li class="list-item">Item four</li>
</ul>
<img src="someimage.jpg" />
<img src="someimage.jpg">
<br />
.......
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en-US">
<head>
</head>
<body>
</body>
</html>
Assignment: Give 3-5 examples of meta-tags and why we use it
<meta name="description" content="my description">
Assignment: Give 3-5 examples of
SocMed Meta tags
Assignment: Find two of each attributes that where not mentioned here
article[data-username='firstname'] {...}
let firstname = document.querySelector('[data-username="firstname"]');
<!DOCTYPE html>
<html lang="en">
<head>
<title>An ID is unique</title>
</head>
<body>
<div id="unique">
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>A class can be repeated</title>
</head>
<body>
<div id="unique">
<p class="maintext">
Here is some text
</p>
<p class="maintext">
Here is some more text
</p>
</div>
</body>
</html>
HTML tags may have a certain default style. You can inspect them in the browser debug console. Examples in Chrome:
"Display" is a style property that can have the following values:
Examples: <html>, <body>, <div>, <p>, <h1>, <h2>, ....
Examples: <span>, <img>
So-called block elements has default {display: block} style. Check what is default style for <span> and <img> tags.
The central goal of HTML is to present text content. There is a set of typography elements with default styles that you can use to markup text.
Assignment: Inspect styles of typography elements in browser console
Non semantic
<div>
<span>
Semantic
<header>
<article>
If the same property was declared on different levels,
CSS will apply it in the following order:
Browser default > External styles > style tag > inline styles.
<html>
<head>
<style>
body {
font-family: verdana;
color: #FFF;
background-color: #000;
}
h2 { color: blue; }
.alert { color: yellow; }
.info { color: lightblue; }
h2.info { color: pink; }
</style>
</head>
<body>
<main class="alert">
<section>
<header>
<h1>Hello world</h1>
<h2>This is my subtitle</h2>
</header>
<article class="main_article">
<h2 class="info">Article header</h2>
<p>Article info</p>
</article>
</section>
</main>
</body>
</html>
<html>
<head>
<style>
body {
font-family: verdana;
color: #FFF;
background-color: #000;
}
h2 { color: blue; }
.alert { color: yellow; }
.info { color: lightblue; }
h2.info { color: pink; }
</style>
</head>
<body>
<main class="alert">
<section>
<header>
<h1>Hello world</h1>
<h2>This is my subtitle</h2>
</header>
<article class="main_article">
<h2 class="info">Article header</h2>
<p>Article info</p>
</article>
</section>
</main>
</body>
</html>
<h1 style="color: red">Red text</h1>
<html>
<head>
<style>
h1 { color: red; }
</style>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
External file
<html>
<head>
<style>
<link rel="stylesheet" href="styles.css" />
</style>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
h1 {
color: red;
}
index.html
styles.css
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<p class="header blue">Hello world</p>
</body>
</html>
p { color: red; }
.blue { color: blue; }
.header { color: green; }
CSS applies styles in the order as stated in the stylesheet (+ order of CSS declarations). What will be the resulting color of the paragraph?
If several style descriptions declare the same property, CSS needs to decide which one to apply. The order of declaration is a guide for decision.
By using the "!important" flag, we can manipulate the default behavior of conflicting styles.
We can't apply "!important" flag to fix occurring style bugs. If we have several styles patched with "!important", it may bring even more complicated cases.
According to the priority of CSS declarations, inline styles must be applied with the highest priority, but "important" flag overrides it as well.
But not if we have "!important" inline styles. After all, you may end up with a bunch of "!important" styles conflicting with each other as well.
General rule: use !important when it's really important. Most of the time you can resolve the conflict in a normal way: change the order of styles, refactor classes, apply inline styles.
"!important" is an exceptional tool to rescue.
Certain CSS architectures try to prevent style conflicts
(OOCSS - object-oriented CSS)
By CodePamoja
This presentation will teach, in an interactive way, the basic usage of HTML5 and semantic elements, and provide a start with basic CSS rules/ specificity.
CodePamoja means "Code Together" in Swahili. We are a group of passionate developers in The Netherlands and Kenya working together in virtual teams, transferring the latest software development skills to each other.