Lesson on Upgrading
HTML Tags to
CSS Style from Udemy online course: Creating a Website Made
Easy
Full course description and 25% discount coupon:
http://tharsishighlands.com/online-courses/creating-a-website-made-easy/
Transcript:
In this lesson, we will take many of the basic
HTML tags and use them as CSS element selectors to upgrade their style. In CSS, the HTML tags are called "elements."
BODY
First, we start with the [body] tag element (YouTube does not allow angle brackets in description).
When you first set up your main CSS file, you typically want to establish the basics for your entire page. These can include,
• background-color
• background-image
• default font-size, color and font-family
All of these can be handled in the body element. For example,
body {
background-color: linen;
background-image: url("pix/tree
.jpg");
font-family:
Vera, Arial,
Helvetica, sans-serif;
font-size: 15px;
color: #24425C;
}
SELECTORS
We've already seen a little about CSS syntax. For example,
h1 { color: blue; }
Each
CSS style starts with a selector and is followed by one or more declarations within open and close braces — each declaration being a property-value pair:
{ property: value }
Element selectors select all HTML tags of the same name. For instance, for the [p] tag,
p { text-align: center; color: red; }
[p]All paragraphs with only the p tag are centered and red. This is a demonstration of how the element selector works.[/p]
The ID selector uses the ID attribute of an
HTML element to select that specific element. ID is a unique identifier. On any one page, there can be only one of that ID. Also, the ID name cannot start with a numeral. For example,
#first_heading { color: red; }
[h1 id="first_heading"]This is the First Heading on the
Page[/h1]
The class selector selects all elements with a specific class attribute
.
.quote {
border-style: solid;
border-width: 1px;
border-color: #880000;
padding: 5px;
font-size: 18px;
font-style: italic;
}
Here, we see a class called "quote" which uses larger type, italics and a dark red border.
Next, is the HTML which uses that class.
[p class="quote"]"There are more things in heaven and earth, Horatio, than are dreamt of in your philosophy."[/p]
A class can be restricted to only one element type. For example,
p.first { text-indent: 0px; }
This can be helpful if all other paragraphs are given an indent. The first paragraph after a heading can be made flush left.
We can also use more than one class at a time. For example,
[p class="first quote"]"
Houston, we have a problem..."[/p]
We've already seen how selectors which share property values can be grouped.
h1, h2, h3 { color: steelblue; }
In the earlier lesson on the
Head section, we learned how to link to an external style sheet — a file with sets of selectors and declarations.
For internal CSS, you have the same selector-declaration combinations, but set within open and close [style] tags.
[head]
[style]
body { background-color: darkslateblue; }
[/style]
[/head]
And for inline CSS, you have the same selector-declaration combinations within a style attribute.
[p style="text-indent: 50px; color: steelblue;"]This is important text.[/p]
Multiple Styles Cascade into One
CSS statements have a sequence of priority. The lowest priority of style is the browser defaults. Next are the external and internal style sheets in the head section.
Sequence matters, so if you link to your external style sheet after the internal style declarations, the external CSS takes priority over the internal.
Finally, the inline style declarations take the highest priority.
For all style information that uses the same selectors, the highest priority replaces the lower priorities. For example,
External:
p {
color: blue;
text-indent: 30px;
}
Internal:
p { color: green; }
Inline:
p { color: red; }
The final style is:
p {
color: red;
text-indent: 30px;
}
Background:
The following properties control the background of
HTML elements.
• background-color
• background-image
• background-repeat
• background-attachment
• background-position
Example:
body {
background-color: blue;
}
As we've already learned, colors can be specified,
• As Hex — like "#00ffff"
• As
RGB — like "rgb(0,255,255)"
• By name — like "aqua"
We will learn more about colors and the new
CSS3 color specification in a later lesson.
Background
Image:
The default behavior of a background image is to repeat the image both vertically and horizontally in order to fill the entire background of the element with the selected picture.
body {
background-image: url("pix/sandbaked
.gif");
}
[...]
In the next lesson, we talk about fonts, tables and links.
Music:
"
Acid Jazz," "
Darkness Speaks," and "
Fanfare for
Space" by
Kevin MacLeod (incompetech.com)
Licensed under
Creative Commons: By Attribution 3.0
http://creativecommons.org/licenses/by/3.0/
Still:
Clear Creek 5 by ImBooToo via Morguefile.com.
- published: 24 Jun 2015
- views: 537