Create Visual Balance Using the text-align Property

Text is often a large part of web content. CSS has several options for how to align it with the text-align property.

text-align: justify; spaces the text so that each line has equal width.

text-align: center; centers the text

text-align: right; right-aligns the text

And text-align: left; (the default) left-aligns the text.

Align the h4 tag’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;

  }
  .links {
    margin-right: 20px;

  }
  .fullCard {
    border: 1px solid #ccc;
    border-radius: 5px;
    margin: 10px 5px;
    padding: 4px;
  }
  .cardContent {
    padding: 10px;
  }
</style>
<div class="fullCard">
  <div class="cardContent">
    <div class="cardText">
      <h4>Google</h4>
      <p>Google was founded by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University.</p>
    </div>
    <div class="cardLinks">
      <a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank" class="links">Larry Page</a>
      <a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank" class="links">Sergey Brin</a>
    </div>
  </div>
</div>

Adjust the Width of an Element Using the width Property

Add a width property to the entire card and set it to an absolute value of 245px. Use the fullCard class to select the element.

.fullCard {

    border: 1px solid #ccc;
    border-radius: 5px;
    margin: 10px 5px;
    padding: 4px;
    width: 245px;
  }

Adjust the Height of an Element Using the height Property

Add a height property to the h4 tag and set it to 25px.

 h4 {
    text-align: center;
    height: 25px;

  }

Use the strong Tag to Make Text Bold

Wrap a strong tag around the text Stanford University inside the p tag (do not include the period).

<p>Google was founded by Larry Page and Sergey Brin while they were Ph.D. students at <strong>Stanford University</strong>.</p>

Use the u Tag to Underline Text

Wrap the u tag only around the text Ph.D. students.

Note: Try to avoid using the u tag when it could be confused for a link. Anchor tags also have a default underlined formatting.

<p>Google was founded by Larry Page and Sergey Brin while they were <u>Ph.D. students</u> <strong>Stanford University</strong>.</p>

Use the em Tag to Italicize Text

To emphasize text, you can use the em tag. This displays text as italicized, as the browser applies the CSS of font-style: italic; to the element.

Wrap an em tag around the contents of the paragraph tag to give it emphasis.

 <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>

Use the s Tag to Strikethrough Text

To strikethrough text, which is when a horizontal line cuts across the characters, you can use the s tag. It shows that a section of text is no longer valid. With the s tag, the browser applies the CSS of text-decoration: line-through; to the element.

Wrap the s tag around Google inside the h4 tag and then add the word Alphabet beside it without the strikethrough formatting.

<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>

Create a Horizontal Line Using the hr Element

You can use the hr tag to add a horizontal line across the width of its containing element. This can be used to define a change in topic or to visually separate groups of content.

Add an hr tag underneath the h4 which contains the card title.

Note: In HTML, hr is a self-closing tag, and therefore doesn’t need a separate closing tag.

<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>
Share on:

Leave a Comment

Your email address will not be published.

error:
Scroll to Top