CSS3 is built upon several modules, where each module is focused on a separate design topic
code.org
HTML is the framing and structure of the house, while CSS is the paint, shingles and siding.
/**Correct Code, but hard to read**/
p {font-family: arial, helvetica, sans-serif;
font-size: 85%; line-height: 110%; margin- left: 30px;}
/**Good CSS coding practice - 1 declaration per line**/
p {
font-family: arial, helvetica, sans-serif;
font-size: 85%;
line-height: 110%;
margin-left: 30px;
}
3 Ways of Implementing CSS
Example of implementing external, internal and inline
Type Selectors | Grouping Selectors | Combining declarations | Using descendant Selectors
/**Specific style rules**/
h1 {color: red;}
h2 {color: red;}
/**Grouping selectors:**/
h1, h2 {color: red;}
/**Specific style rules**/
p {color: blue;}
p {font-size: 125%;}
/**Combining declarations**/
p {
color: blue;
font-size: 125%;
}
/**Selecting only <em> elements that are contained
within <p> elements**/
p em {
color: blue;
}
/**Selecting all children of the div element:**/
div * {
font-family: sans-serif;
}
Universal selector lets you select groups of elements
<h1> This is a fun <em> activity </em> on CSS </h1>
<p> Understanding <em> style rules </em> in CSS </p>
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
body {
line-height:1;
}
/**Specific style rules**/
h1 {color: red;}
p {color: red;}
ul {color: red;}
em {color: red;}
li {color: red;}
/**Using Inheritance to reduce code**/
body {color: red;}
Style inheritance promotes good coding practice and faster updates when changes need to be made to the code.
*Pseudo-classes select elements based on characteristics other than their element name
*Pseudo-elements let you change other aspects of a document that are not classified by standard elements such as the first letter or line of a paragraph.
/**Example**/
a:hover {
background-color: lime;
color: #333;
}
<nav id="navstruct">
<ul>
<li><a href="index.html">Home </a></li>
<li><a href="store_history.html">Story History </a></li>
<li><a href="unit_history.html">Unit History </a></li>
</ul>
<img src="https://reacttees.com/images/logo1.png/" alt="logo" />
</nav>
Which HTML tag is used to define an internal style sheet?
Which HTML attribute is used to define inline style?
Which is the correct CSS Syntax?
How do you select an element with id "demo"?
What is the correct HTML syntax for inserting an image?