Styling HTML5 Using CSS3

Tutorial 6: How Do We Include CSS In Our HTML by Danny Nelson


CSS is responsible for the look and feel of a website. One can set up the background color, font color, image sizes, font type...etc. through CSS. CSS is able to do this by selecting certain elements of HTML to style. For example, I changed the body's background color by using the CSS selector background css selector. I targeted the h1 element in CSS and centered it like so h1 tag. The HTML tags that are targeted in this process are also known as CSS selectors.

But what about the h2 tag? Even though h2 is also a heading tag, the number 2 distingushes it from the h1 tag so there is no need to further distinguish it with a .class or #id tag. As you can see from the image, the h2 tag is used as a CSS selector to center the heading h2 tag.

Lastly, you will notice a few edits with the dahlia image image style in css. Images taken from the internet are often very large so it is important to learn how to scale them down so they can fit on your page. I managed to scale the width of the photo to thirty percent of its container (the web page). I was able to center it by setting the right and left margins to auto. When the margins are set to auto they fight for space, leaving html items stuck in the middle of the web page.


sample css photo dahlia web page