Posted on Leave a comment

Styling Our About Me Page With CSS

[callaction url=”https://www.youtube.com/user/JPlaya01″ background_color=”#333333″ text_color=”#ffffff” button_text=”Go Now” button_background_color=”#e64429″]Subscribe To My Youtube Page[/callaction]

Cascading Style Sheets

Cascading Style Sheets or CSS is the language that describes how HTML documents are displayed. In other words it is the language that styles the web. It is the 2nd cornerstone of web development, with the 3rd being javascript. Like with all my tutorials I will give you a brief introduction to the language and teach you the innerworks bit by bit over various demos.

Our Current Situation

If you have been following along then you should have a basic about me page built. Here is mine:

<!DOCTYPE html>
<html>
<head>
<title>About Jyrone Parker</title>
</head>
<body>
<h1>Hi I Am Jyrone Parker</h1>
<img src="https://en.gravatar.com/userimage/70717632/53adbdecac04d4ffbe3449993c901a73.jpg?size=200"/>
<audio loop autoplay>
<source src="http://freesound.org/data/previews/353/353234_3162775-lq.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<p> I am CEO and lead engineer at J Computer Solutions LLC, a consultancy that places software and DevOps engineers at companies in need.
<div itemscope itemtype="http://schema.org/LocalBusiness">
<h1 itemprop="name">Contact Me</h1>
Phone: <span itemprop="telephone">
<a href="tel:+18594024863"> 859-402-4863</a>
</span>
</div>
</p>
</body>
</html> 

As it stands currently this page is UGLY! I’m going to import a CSS framework to start off with. A framework basically is a bunch a code that boilerplates stuff for you, so you can focus more on the core of what you are trying to accomplish. My framework of choice is Bootstrap the way you add CSS code to your HTML markup is via the <link> tag. In the head of your document add the following:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

This will load the latest bootstrap css into your webpage. Notice the href does not have to be a remote address. If you have a folder called css/ and downloaded the bootstrap code you can call it like href=”css/bootstrap.css”.

Prepping The HTML

Before we do any styling we need to add a few <meta> tags to the top of the <head> section for Bootstrap to work properly. Please add  the following right below the <head> tag:


<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

Elements, IDs & Classes

CSS can interact with the HTML document via elements, ids, and classes. An Element is a tag such as <body> or <h1>. An id points to one specific tag on an HTML document and ONLY one such as <title id=”about-me-page-title”>. A class applies a style to every element with that class AND everything in between that element such as


<div class="cool-section">
<p id="cool-paragraph">
Some text goes here
</p>
</div>

In this example both <div> AND  <p> have the class “cool-section” applied to it because <p> is a child of <div>; However <p> has addition styling that <div> does not because of its id.
 

Creating main.css

I know I said we would be using Bootstrap to do our styling, but I want to make one addition to the background color of the body. Create a folder called css and in that folder create a folder called main.css. In a CSS file the syntax is as follows


element{
property:value;
}

or


#id{
property:value;
}
.class{
property:value;
}

Since I want to change the body element and I want to change the background color to this nice gray I like I put in the following rule:<pre><code class=”language-css”>


body{
background-color: #667;
}

If you are wondering how #667 = gray, it’s because HTML uses hexadecimal for color, here is a good reference if you need it http://www.w3schools.com/colors/colors_picker.asp. Save the file and right below the Bootstrap link place this link

<link rel="stylesheet" href="css/main.css">

Navigation Bar

One of the bootstrap components is the nav bar. HTML5 added a <nav> tag that defines a set of navigation links for your document. Copying the example snippet from the Bootstrap website and removed what wasn’t needed.


<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Jyrone Parker</a>
</div>
</div><!-- /.container-fluid -->
</nav>

Ignore all of the data- attributes right now that’s javascript related, but notice all of the classes in this section these are pre-defined Bootstrap styles. I suggest getting familiar with the documentation. Add this nav bar right below your opening <body> tag refresh your page and notice the changes.
 

Styling Content

The first thing I want to do is make my content a fixed width, this will give it a consistent look across devices. To do this I will wrap all my content (minus nav) in a div with class container. I also want everything in this div to stand out. Luckily Bootstrap has a class for content you want to stand out it’s called jumbotron. Lastly we want all text to be centered, Bootstrap provides a text-center defintion.
<div class=”container jumbotron text-center”>
//previous code
</div>
The finishing touch will be preformed on our profile picture. Bootstrap offers some img classes to help us. On the <img> tag add the following classes:


<img class="img img-rounded" src="https://en.gravatar.com/userimage/70717632/53adbdecac04d4ffbe3449993c901a73.jpg?size=200"/>

Now save and refresh the page, notice how much better it looks? In case you missed anything here is what my page markup looks like:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<title>About Jyrone Parker</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="css/main.css">
</head>
<body id="">
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Jyrone Parker</a>
    </div>
  </div><!-- /.container-fluid -->
</nav>
<div class="container">
	<div class="jumbotron text-center">
<h1>Hi I Am Jyrone Parker</h1>
<img class="img img-rounded" src="https://en.gravatar.com/userimage/70717632/53adbdecac04d4ffbe3449993c901a73.jpg?size=200"/>
<audio loop autoplay>
<source src="http://freesound.org/data/previews/353/353234_3162775-lq.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<p>
I am CEO and lead engineer at J Computer Solutions LLC, a consultancy that places software and DevOps engineers at companies in need.
<div itemscope itemtype="http://schema.org/LocalBusiness">
	<h1 itemprop="name">Contact Me</h1>
		Phone: <span itemprop="telephone"><a href="tel:+18594024863">
859-402-4863</a></span>
</div>
</div>
</p>
</div>
</body>
</html>

You can also see my latest code on Github. Next we are going to add some interactiveness with some javascript!! If you haven’t already please subscribe to my blog via email to get notifications on when I post. If you have any questions please leave them in the comments!d

Posted on Leave a comment

A Primer To HTML

[callaction url=”https://www.youtube.com/user/JPlaya01″ background_color=”#333333″ text_color=”#ffffff” button_text=”Go Now” button_background_color=”#e64429″]Subscribe To My Youtube Page[/callaction]

What Is HTML?

HTML is short for Hyper Text Markup Language. It is the language that describes web pages. Every web page is made up of HTML if you don’t believe me right-click on any webpage and select “view source”; You will see the HTML that makes up that particular page. HTML consists of tags usually in the form of <tag>CONTENT </tag>. Below is an example of a minimum HTML document or webpage


<!DOCTYPE html>


<html>


<head>
<title> My First Webpage! </title>
</head>
<body>
HELLO WORLD!
</body>
</html>

 

If you copy and paste that into an empty document and save it as index.html. Now launch your web browser of choice and open the file you just created. You should see the words “HELLO WORLD!” pop up on the screen with a title of “My First Webpage”. Now let’s break down what each tag means

  • The <!DOCTYPE html> declaration defines this document to be HTML5
  • The text between <html> and </html> describes an HTML document
  • The text between <head> and </head> provides information about the document
  • The text between <title> and </title> provides a title for the document
  • The text between <body> and </body> describes the visible page content

A simple way I like to think about it is the head section is used by the browser and search engines, where the content of the body is what the user of the browser will see and interact with.

Useful Tags

HTML has hundreds of tags, the vast majority of which you will probably never use, however here are a few you should get really familiar with.

  • <p> – Defines a paragraph
  • <h1> to <h6> – Define headings with h1 being the most important heading, to h6 being the least
  • <a href=”http://someurl”> – Defines a link tag where href= the remote link
  • <img src=”/link/to/image”> – Defines an image
  • <video src=”/link/to/video”> – Defines a video
  • <audio src=”/link/to/audio”> – Defines an audio source

Of course you have full range to look at all the tag definitions here. Next we will create a simple about me page, utilizing git in the process! So if you aren’t familiar with git you should start here. Also don’t forget if you haven’t already subscribe to my blog via email to get real-time updates on whenever I post! Be sure to leave comments below they are greatly appreciated!