140 likes | 404 Vues
Learn the fundamentals of HTML and CSS to create visually appealing web pages. This guide covers essential topics, including how to structure a simple HTML page for summarizing blog posts, the roles of block (div) and inline (span) elements, and using CSS to enhance visual aesthetics. Understand the importance of selectors, property setting, and color representation (RGB, hex codes) while ensuring readability and distinctiveness across elements. Explore font size adjustment and discover best practices for creating an attractive and functional web design.
E N D
HTML review and CSS Looking stylish!
But first… • Any issues with the reading? • Any questions with the reading?
Today • Using HTML to make a meaningful page • Using CSS to make a nice-looking page • How to use selectors to select specific elements • How to set various properties • How classes can be useful
HTML review • Let's go ahead and make a simple HTML page that represents a summary of blog posts
div and span • Sometimes, we want to create a block element (div) or inline element (span) that isn't one of the predefined meanings • Once we add CSS, these will make a lot more sense
Styling it up • We want to make our blog look a lot more exciting • We are going to add CSS to specify how we want things to look • Let's look at CSS syntax…
Simple selectors • The simplest selector is simply a tag name • For instance, let's write a selector to select all paragraph text…
Simple properties • The simplest properties affect the color of elements • We can set the text color using "color:" • We can set the background color using "background-color:" • Let's see how to represent color, and then start making things pretty
Color: RGB and you • Colors in a computer are represented by a certain amount of red, green, and blue light • These lights combine to form the colors we see • We have one byte for each of R, G, and B • Each can range from 0-255 • We can specify color in a few ways…
Full red • rgb(255, 0, 0) • #ff0000 • #f00 • red • For a full list of named colors, see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value • For pure grays, all components are the same • #333, #999 #ccc, etc.
Assigning colors responsibly • Try to assign colors to various selectors so that: • Each article is distinct from other articles • The article text is distinct from the text for the article information and the tags • All text is legible • It doesn't hurt to look at • You probably want selectors for: • section • h2 • p • div • ul
Adjusting font size • To adjust font size, use the property "font-size:" • After the colon, indicate a length • We have different units to choose from: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#Numbers_lengths_and_percentages
Adjusting font size • To adjust font size, use the property "font-size:" • After the colon, indicate a length • We have different units to choose from: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#Numbers_lengths_and_percentages • Typically, you will use • px – pixels • % – percentage (relative to… something) • em – amount relative to parent text size • rem – amount relative to "html" element text size