Introduction To The Applied Visual Design Challenges
Introduction To The Applied Visual Design Challenges
At a basic level, most web content provides a user with information. The visual design
of the page can influence its presentation and a user's experience. In web development,
HTML gives structure and semantics to a page's content, and CSS controls the layout
and appearance of it.
This section covers some of the basic tools developers use to create their own visual
designs.
Text is often a large part of web content. CSS has several options for how to
align it with the text-alignproperty.
text-align: justify;causes all lines of text except the last line to meet the left
and right edges of the line box.
Align the h4tag's text, which says "Google", to the center. Then justify the
paragraph tag which contains information about how Google was founded.
<style>
h4 {
text-align:center;
}
p {
text-align:justify;
}
img {
width: 220px;
}
Add a widthproperty to the entire card and set it to an absolute value of 245px.
Use the fullCardclass to select the element.
img {
height: 20px;
}
<h4><s
>Google</s> Alphabet</h4>
<p><em>Google was founded by Larry Page and Sergey Brin while they
were <u>Ph.D. students</u> at <strong>Stanford
University</strong>.</em></p>
Note
In HTML, hris a self-closing tag, and therefore doesn't need a separate closing
tag.
<style>
h4 {
text-align: center;
height: 25px;
}
p {
text-align: justify;
}
.links {
text-align: left;
color: black;
}
.fullCard {
width: 245px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 10px 5px;
padding: 4px;
}
.cardContent {
padding: 10px;
}
.cardText {
margin-bottom: 30px;
}
</style>
<div class="fullCard">
<div class="cardContent">
<div class="cardText">
<h4><s>Google</s>Alphabet</h4>
<hr>
<p><em>Google was founded by Larry Page and Sergey Brin while they
were <u>Ph.D. students</u> at <strong>Stanford
University</strong>.</em></p>
</div>
<div class="cardLinks">
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank"
class="links">Larry Page</a><br><br>
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank"
class="links">Sergey Brin</a>
</div>
</div>
</div>
Note
In HTML, hris a self-closing tag, and therefore doesn't need a separate closing
tag.
The RGB values can range from 0 to 255. The alpha value can range from 1,
which is fully opaque or a solid color, to 0, which is fully transparent or
clear. rgba()is great to use in this case, as it allows you to adjust the opacity. This
means you don't have to completely block out the background.
<style>
h4 {
text-align: center;
background-color: rgba(45,45,45,0.1);
padding: 10px;
}
p {
text-align: justify;
}
.links {
text-align: left;
color: black;
}
.fullCard {
width: 245px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 10px 5px;
padding: 4px;
}
.cardContent {
padding: 10px;
}
.cardText {
margin-bottom: 30px;
}
</style>
<div class="fullCard">
<div class="cardContent">
<div class="cardText">
<h4>Alphabet</h4>
<hr>
<p><em>Google was founded by Larry Page and Sergey Brin while they
were <u>Ph.D. students</u> at <strong>Stanford
University</strong>.</em></p>
</div>
<div class="cardLinks">
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank"
class="links">Larry Page</a><br><br>
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank"
class="links">Sergey Brin</a>
</div>
</div>
</div>
Applied Visual Design: Adjust the Size of a Header
Versus a Paragraph Tag
The font size of header tags (h1through h6) should generally be larger than the
font size of paragraph tags. This makes it easier for the user to visually
understand the layout and level of importance of everything on the page. You
use the font-sizeproperty to adjust the size of the text in an element.
To make the heading significantly larger than the paragraph, change the font-
sizeof the h4tag to 27 pixels.
<style>
h4 {
text-align: center;
background-color: rgba(45, 45, 45, 0.1);
padding: 10px;
font-size:27px;
}
p {
text-align: justify;
}
.links {
text-align: left;
color: black;
}
.fullCard {
width: 245px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 10px 5px;
padding: 4px;
}
.cardContent {
padding: 10px;
}
.cardText {
margin-bottom: 30px;
}
</style>
<div class="fullCard">
<div class="cardContent">
<div class="cardText">
<h4>Alphabet</h4>
<hr>
<p><em>Google was founded by Larry Page and Sergey Brin while they
were <u>Ph.D. students</u> at <strong>Stanford
University</strong>.</em></p>
</div>
<div class="cardLinks">
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank"
class="links">Larry Page</a><br><br>
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank"
class="links">Sergey Brin</a>
</div>
</div>
</div>
Here's an example of the CSS to create multiple shadows with some blur, at
mostly-transparent black colors:
The element now has an id of thumbnail. With this selector, use the example CSS
values above to place a box-shadowon the card.
<style>
h4 {
text-align: center;
background-color: rgba(45, 45, 45, 0.1);
padding: 10px;
font-size: 27px;
}
p {
text-align: justify;
}
.links {
text-align: left;
color: black;
}
.fullCard {
width: 245px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 10px 5px;
padding: 4px;
}
.cardContent {
padding: 10px;
}
.cardText {
margin-bottom: 30px;
}
#thumbnail{
box-shadow:0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}
</style>
<div class="fullCard" id="thumbnail">
<div class="cardContent">
<div class="cardText">
<h4>Alphabet</h4>
<hr>
<p><em>Google was founded by Larry Page and Sergey Brin while they
were <u>Ph.D. students</u> at <strong>Stanford
University</strong>.</em></p>
</div>
<div class="cardLinks">
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank"
class="links">Larry Page</a><br><br>
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank"
class="links">Sergey Brin</a>
</div>
</div>
</div>
<style>
h4 {
text-align: center;
background-color: rgba(45, 45, 45, 0.1);
padding: 10px;
font-size: 27px;
}
p {
text-align: justify;
}
.links {
text-align: left;
color: black;
opacity:0.7;
}
#thumbnail {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}
.fullCard {
width: 245px;
border: 1px solid #ccc;
border-radius: 5px;
margin: 10px 5px;
padding: 4px;
}
.cardContent {
padding: 10px;
}
.cardText {
margin-bottom: 30px;
}
</style>
<div class="fullCard" id="thumbnail">
<div class="cardContent">
<div class="cardText">
<h4>Alphabet</h4>
<hr>
<p><em>Google was founded by Larry Page and Sergey Brin while they
were <u>Ph.D. students</u> at <strong>Stanford
University</strong>.</em></p>
</div>
<div class="cardLinks">
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank"
class="links">Larry Page</a><br><br>
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank"
class="links">Sergey Brin</a>
</div>
</div>
</div>
Applied Visual Design: Use the text-transform
Property to Make Text Uppercase
The text-transformproperty in CSS is used to change the appearance of text. It's
a convenient way to make sure text on a webpage appears consistently, without
having to change the text content of the actual HTML elements.
Value Result
}
</style>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
</p>
For example, the styling of an anchor tag can be changed for its hover state
using the :hoverpseudo-class selector. Here's the CSS to change the colorof the
anchor tag to red during its hover state:
a:hover {
color: red;
}
The code editor has a CSS rule to style all atags black. Add a rule so that when
the user hovers over the atag, the coloris blue.
<style>
a {
color: #000;
}
a:hover{
color:blue;
}
</style>
<a href="http://freecatphotoapp.com/" target="_blank">CatPhotoApp</a>
Applied Visual Design: Change an Element's Relative
Position
CSS treats each HTML element as its own box, which is usually referred to as
the CSS Box Model. Block-level items automatically start on a new line (think
headings, paragraphs, and divs) while inline items sit within surrounding
content (like images or spans). The default layout of elements in this way is
called the normal flowof a document, but CSS offers the position property to
override it.
When the position of an element is set to relative, it allows you to specify how
CSS should move it relative to its current position in the normal flow of the
page. It pairs with the CSS offset properties of leftor right, and topor bottom.
These say how many pixels, percentages, or ems to move the item away from
where it is normally positioned. The following example moves the paragraph 10
pixels away from the bottom:
p {
position: relative;
bottom: 10px;
}
Changing an element's position to relative does not remove it from the normal
flow - other elements around it still behave as if that item were in its default
position.
Note
Positioning gives you a lot of flexibility and power over the visual layout of a
page. It's good to remember that no matter the position of elements, the
underlying HTML markup should be organized and make sense when read from
top to bottom. This is how users with visual impairments (who rely on assistive
devices like screen readers) access your content.
}
</style>
<body>
<h1>On Being Well-Positioned</h1>
<h2>Move me!</h2>
<p>I still think the h2 is where it normally sits.</p>
</body>
Use CSS offsets to move the h215 pixels to the right and 10 pixels up.
Your code should use a CSS offset to relatively position the h210px upwards. In
other words, move it 10px away from the bottomof where it normally sits.
Your code should use a CSS offset to relatively position the h215px towards the
right. In other words, move it 15px away from the leftof where it normally sits.
<head>
<style>
h2 {
position: relative;
bottom:10px;
left:15px;
}
</style>
</head>
<body>
<h1>On Being Well-Positioned</h1>
<h2>Move me!</h2>
<p>I still think the h2 is where it normally sits.</p>
</body>
One nuance with absolute positioning is that it will be locked relative to its
closest positioned ancestor. If you forget to add a position rule to the parent
item, (this is typically done using position: relative;), the browser will keep
looking up the chain and ultimately default to the body tag.
}
section {
position: relative;
}
</style>
<body>
<h1>Welcome!</h1>
<section>
<form id="searchbar">
<label for="search">Search:</label>
<input type="search" id="search" name="search">
<input type="submit" name="submit" value="Go!">
</form>
</section>
</body>
width: 100%;
background-color: #767676;
}
nav ul {
margin: 0px;
padding: 5px 0px 5px 30px;
}
nav li {
display: inline;
margin-right: 20px;
}
a {
text-decoration: none;
}
</style>
<body>
<header>
<h1>Welcome!</h1>
<nav id="navbar">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Contact</a></li>
</ul>
</nav>
</header>
<p>I shift up when the #navbar is fixed to the browser window.</p>
</body>