HTML5 and CSS3 Tutorial #3: Drop-Down Navigation Bar with “:hover” Pseudo Class, and Unordered Lists

Courtesy Note: If you found this tutorial useful, please take a few moments to comment below!

The following notable HTML5/CSS3 topics will be covered in this tutorial:

1. “:hover” pseudo-class
2. “white-space” CSS3 property
3. “position: absolute” CSS3 property
4. “display” CSS3 property


This is probably one of the more frustrating features to code for your own site when you’re a beginner. A drop down navigation bar could be one of the most essential features on your website believe it or not. If you have a lot of content and links, and need help on coding a navigation bar that handles drop-down menus, then this solution is for you. There could be better solutions out there, using different HTML elements, but this is the solution that I was able to come up with.

I’ll post the screenshots of the original navigation bar, and the navigation bar after it was hovered over, to show that the dropdown menu actually works. I know there’s a better way to do this, such as having you test the navigation bar yourself on my blog, but unfortunately I can’t handle that feature. Sorry for any inconveniences, but the code does work!

Original Navigation Bar:
initial_navigation_bar

Navigation Bar Displaying Drop Down Menu, After Hovering Over “Profile” Tab:
dropdown_menu

Questions? Feedback? Please leave a comment!

HTML Code:

[sourcecode language=”html” collapse=”false” wraplines=”false”]

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Dropdown Menu Demo</title>
<link rel="stylesheet" href="styles.css">
</head>

<body>
<div id="navigation"> <!– Navigation id not used as selector in CSS file. –>
<ul>
<li><a href="#">Home</a>
<ul class="dropdown">
<li><a href="#">Games</a></li>
<li><a href="#">Anime</a></li>
</ul>
</li> <!– END: Home –>

<li><a href="#">Profile</a>
<ul class="dropdown">
<li><a href="#">Edit Profile</a></li>
<li><a href="#">Settings</a></li>
<li><a href="#">Log Out</a></li>
</ul>
</li> <!– END: Profile –>

<li><a href="#">About</a>
<ul class="dropdown">
<li><a href="#">About Us</a></li>
<li><a href="#">Executive Team</a></li>
</ul>
</li> <!– END: About –>

<li><a href="#">Support</a>
<ul class="dropdown">
<li><a href="#">Contact Us</a></li>
<li><a href="#">Feedback</a></li>
</ul>
</li> <!– END: Support –>

</ul>
</div>
</body>
</html>

[/sourcecode]

CSS Code:

[sourcecode language=”css” collapse=”false” wraplines=”false”]
ul {
list-style:none;
margin:0; /* Demonstration purposes to keep navigation menu in top left corner. */
padding:0;
}

ul li {
float:left; /* Puts tabs on same line */
}

ul li a {
display:block; /* Displays links on separate lines. */
color:#000000;
padding:5px 15px 5px 15px; /* 5px top, 15px right, 5px bottom, 15px left */
margin-top:1px; /* Separates dropdown links by whitespace */
margin-left:1px; /* Separates tabs by whitespace */
background-color:#CCCCCC;
white-space:nowrap; /* Doesn’t wrap words across separate lines if line is too long for parent’s li width. This is for the dropdown menu. */
}

li:hover ul { /* Displays dropdown menu for specific li element, once mouse hovers over li element */
position:absolute; /* Positions directly under the correct tab */
display:block;
}

li:hover li { /* Keeps li elements same width in dropdown menu, since it’s originally floating left, as specified in "ul li" selector */
float:none;
}

li:hover a {
background-color:#252525; /* Changes background color of tab and dropdown links to shade of black when tab is hovered over */
color:#FFFFFF; /* Changes text color of tab and dropdown links to white when tab is hovered over. */
}

a {
text-decoration:none; /* So that links aren’t underlined */
}

.dropdown {
display:none; /* Anything in dropdown class doesn’t appear initially when page loads */
}

.dropdown li:hover a {
text-decoration:underline; /* Underlines link if li element in dropdown menu is hovered over */
}

.dropdown li a:hover {
background-color:#CCCCCC; /* Changes background color of link in dropdown menu to grey when we hover over link */
color:#000000; /* Changes text color of link in dropdown menu to black when we hover over link */
}
[/sourcecode]

P.S:

You’re probably a motivated web developer who wants to freelance, blog, and/or be the best developer you can be. I feel many developers suffer from lack of clarity on their career/life, and poor time management and productivity practices. Without clarity and without the commitment to maximize your time, you don’t give yourself the ability to even work on your website projects and hone your coding skills with maximum efficiency.
To be the best coder, blogger, or freelancer you can be, it helps to master the non-technical aspects of entrepreneurship and personal growth. To begin building a solid foundation, I highly recommend that you consider getting my mentor’s free entrepreneurship book and training right now, where he shares his top 30+ tips that he followed in order to become a multi-million dollar entrepreneur in his 20s. I’ve read it, and as a blogger and web developer, it’s made a huge difference in my career outlook and my productivity! In addition, you may also find his productivity and time management master class useful to sign up for!
Remember that the book is free, so be sure to get it here now because I’m not sure if he’s planning to remove the book off the website! Obviously you have the choice, but I truly believe that you will learn some valuable lessons from it, like I have as a fellow blogger and developer. Please let me know if you have any questions, and I’d love to hear what you learn from the book!

teb-fb

Writer’s Block

Lol, writer’s block? Seriously?

No but seriously, it’s been about a month since I updated my blog. Maybe I’m just occupied by the website I’ve been developing this summer. Maybe it’s because I’ve been occupied by some of my other interests as well. Or, it’s probably both reasons. Or, maybe I just don’t know what to write about.

My blog does have different types of content after all. Which areas do I contribute content into first?

Anyways, that’s not the point. I’m here again, and I’m here to talk about what’s been going on the past 30 days, since I actually have the time to :D.

Hyakki's Corner
Hyakki’s Corner – Buying Games So You Don’t Have To

Aside from seeing my lovely friends everyday, it’s been a very productive month. Hyakki’s Corner (the gaming website I’ve dedicated 90% of my summer to) is making A LOT of progress. I’ll talk about the website more some time in the future, but I’m pretty proud of being able to see my own work out there on the web that the entire public can see. Though it’s not even close to being done, it’s really satisfying to be able to display my work to the entire world, and have another reason to play my video games: not only for my pure satisfaction and enjoyment, but because I can apply my writing abilities (I enjoy writing, by the way, which is why I have my own blog lol) by flushing out guides and reviews on Hyakki’s Corner for whatever games I enjoy.

Hyakki’s Corner and video games wasn’t all I wanted to talk about though. My laptop sucks. Like, really sucks, by my standards. I can do a whole lot on this laptop, and it’s probably more powerful than a lot of laptops out there, but it’s so frustrating to deal with. Blue screen of death. Screen locks. Slow performance. Constant disconnections from Wi-Fi. Actually I take that back, this laptop isn’t that powerful anymore. With 4 GB of RAM, and only 2.67 usable, and an lol-i3 processor, what the hell can you do at all? There’s so much I have to worry about with this laptop. Sure I can run skype, and do my programming on it, and browse the web, but I am so frustrating with how slow the laptop runs, especially when I have several applications and tabs open. I have to close several things when I wanna run a new application, and I always have to keep track of my Physical Memory and CPU Usage through the Windows Task Manager. It’s just, ugh. Which brings me to this bad boy:

new computer
AMD Eight-Core Processor @ 4 GHz, 16GB RAM, 2TB HDD, NVIDIA GTX 660 Ti

Okay, the image means nothing without some details on the specs, but I’m not sure who’s reading this so I’m not sure if talking about the details would be a complete waste of your time. You just basically need to know that I got this for $1100 (which isn’t bad honestly for its specs), and that it’s literally 1000x more powerful than my laptop. And with this computer, I get to play FFXIV 2.0 when it comes out baby! High settings too! And of course, I can do my usual computer programming, web browsing, photoshop, etc etc with no inconveniences (at least, less inconveniences). Overall, I’m happy with my purchase, even though it’s the most expensive purchase I have ever made in my entire life. But, since it’s not portable, I’ll probably buy a new laptop too at a bargain price, and leave my PC for use when I’m at my dorm at USF. Which I’m okay with.

And with that, I’m signing off for now. I wanted to talk about some job and internship inquiries that professionals have contacted me about this summer, but I’ll save that for another time. This post is getting too long anyways up to the point that you probably didn’t even read everything as you’re reading this last paragraph. On a final note, I’ll be uploading personal solutions to coding various sorting algorithms in programming, so look out for that if you’re a programmer!

HTML5 and CSS3 Tutorial #2: Preventing Page Content From Wrapping When Re-sizing the Browser Window

Courtesy Note: If you found this tutorial useful, please take a few moments to comment below!

The following HTML5/CSS3 topics will be covered in this tutorial:

1. “min-width” and “max-width” CSS3 properties
2. “margin” CSS3 properties
3. Text-wrapping


This is a rather simple tutorial on a problem that all web developers have experienced in the beginning stages of their website development: text wrapping when the web browser window is re-sized.

By default, when you design your website and add content to it, your  web browser will automatically make your content wrap in each container element to ensure that your text fits on the page when you re-size your browser from left-to-right/right-to-left. But, most web developers don’t want that to happen on their pages. It’s ugly, first of all, and second of all it’s rather unappealing to your web page viewers if all your content was displayed differently depending on the size of the user’s window.

So, how do you fix that? This tutorial will show you a very easy solution to this problem.

First of all, let’s look at a very basic web page that I made (along with it’s HTML5 and CSS3 code).

Web Page (on a maximized browser window):

Web Page Displayed on Maximized Browser
Web Page Displayed on Maximized Browser

HTML5 Code:

[sourcecode language=”html” wraplines=”false” collapse=”false”]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Fixed Width Demonstration</title> <!– Title of tab on browser –>
<link rel="stylesheet" href="layout.css" /> <!– MAKE SURE TO LINK TO THE STYLESHEET WITH THIS LINE,
OTHERWISE YOU CAN’T USE THE STYLESHEET BECAUSE IT’S NOT BEING REFERENCED TO –>
</head>

<body>

<div id="wrapper"> <!– Will use "wrapper" styles in css file. –>

<header> <!– Will use "header" styles in css file. –>
<h1>Header</h1>
</header> <!– End of header –>

<div id="content"> <!– Will use "content" styles in css file. –>
<p>Hello World! My name is Jourdan Bul-lalayao and blah blah blah, yada yada yada. This is a demonstration, yada yada yada.
I’m showing you how to ensure that elements on your page don’t overlap other elements as the web browser resizes, and
to make sure your content doesn’t flow accordingly with the size of the web browser either.</p>
</div> <!– End of content –>

<footer> <!– Will use "footer" styles in css file. –>
<h1>Footer</h1>
</footer> <!– End of footer –>

</div> <!– End of wrapper –>
</body>
</html>

[/sourcecode]

CSS3 Code (file: layout.css):

[sourcecode language=”css” collapse=”false” wraplines=”false”]
#wrapper {
width:80%;
margin-left:auto; /* "auto" to help center the wrapper along with margin-right */
margin-right:auto; /* "auto" to help center the wrapper along with margin-left */
background-color:#CCCCCC; /* Hexadecimal representation for a light gray color. */
}

#content, header, footer { /* Notice that we can use several selectors for other elements if they each contain the same styles, instead of
writing each selector seperately */
border-style:solid; /* Displays border for wrapper element with help of the 2 following lines of code*/
border-color:black;
border-width:medium;
margin-bottom:10px; /* Ensures that other elements under these selectors are placed 10 pixels below. */
}
[/sourcecode]


Let’s take a quick look at exactly what problem I’m talking about. If you’ll notice in the following screenshot, the text in the “content” section of the page wraps (i.e. the text is forced to fit in the browser, even at a smaller sized window. Which means the content section shifts in size and shape, too) based on the size of the web browser’s window. But, it’s not just the “content” section that’s wrapping. The header and footer elements are wrapping as well, and you’ll notice that because they change in shape and size too:

Display on Resized Browser Window
Display on Resized Browser Window

Now, how do you fix this problem? Very easy. For this demonstration, we will be adding the min-width and max-width properties to the wrapper’s style in the css file, and giving those properties a fixed value. We will also be deleting the “width:80%” style for the wrapper, since its width will be fixed already based on how many pixels we specify for the “min-width” and “max-width” properties. For this demonstration, we will be using 960 pixels for both properties. Basically, with a min-width of 960px and a max-width of 960px, the wrapper element’s width, no matter what the size of the browser window is, will ALWAYS be 960 pixels; no more, and no less. You can specify another number for the min-width/max-width properties based on how wide you want your wrapper to look like in the browser, but for this demonstration it will be 960 pixels.

Here is a screenshot of the solution to the problem we examined, along with the new CSS3 code. We did not have to change anything in the HTML5 code.

New Web Page Without Wrapping Content:

New Display
New Display after using min-width and max-width properties

New CSS Code (file: layout.css):

[sourcecode language=”css” wraplines=”false” collapse=”false”]
#wrapper {
margin-left:auto;
margin-right:auto;
background-color:#CCCCCC;
min-width:960px; /* MIN-WIDTH PROPERTY ADDED */
max-width:960px; /* MAX-WIDTH PROPERTY ADDED */
}

#content, #header, #footer {
border-style:solid;
border-color:black;
border-width:medium;
margin-bottom:10px;
}
[/sourcecode]


Note: If you want to keep the same margins around the wrapper, you will have to specify a specific number for the amount of pixels you want in the margins, instead of using “margin-left:auto”, like this demonstration uses.

Questions/Feedback? Please comment!

P.S:

You’re probably a motivated web developer who wants to freelance, blog, and/or be the best developer you can be. I feel many developers suffer from lack of clarity on their career/life, and poor time management and productivity practices. Without clarity and without the commitment to maximize your time, you don’t give yourself the ability to even work on your website projects and hone your coding skills with maximum efficiency.
To be the best coder, blogger, or freelancer you can be, it helps to master the non-technical aspects of entrepreneurship and personal growth. To begin building a solid foundation, I highly recommend that you consider getting my mentor’s free entrepreneurship book and training right now, where he shares his top 30+ tips that he followed in order to become a multi-million dollar entrepreneur in his 20s. I’ve read it, and as a blogger and web developer, it’s made a huge difference in my career outlook and my productivity! In addition, you may also find his productivity and time management master class useful to sign up for!
Remember that the book is free, so be sure to get it here now because I’m not sure if he’s planning to remove the book off the website! Obviously you have the choice, but I truly believe that you will learn some valuable lessons from it, like I have as a fellow blogger and developer. Please let me know if you have any questions, and I’d love to hear what you learn from the book!

teb-fb

 

HTML5 & CSS3 Tutorial: Basic Web Layout With divs, id selectors, unordered lists, and floats

Courtesy Note: If you found this tutorial useful, please take a few moments to comment below!

The following notable HTML5/CSS3 topics will be covered in this tutorial:

1. New HTML5 Tags (header, nav, footer)
2. ‘id’ selectors
3. Unordered lists (‘ul’ HTML tag)
4. ‘float’ and ‘clear’ CSS3 properties


For those of you who don’t know, I’ve been working on a huge website project for the past few weeks and in doing so, I’ve familiarized myself and learned a whole lot about HTML5 and CSS3, and through my struggles of coding certain features, I had the inspiration of posting basic coding tutorials of how to perform certain tasks and do certain designs in HTML and CSS. The first tutorial I will be providing on this blog is making a basic web layout. This will also be posted in the “Code” section.

This will be a very basic tutorial of how to make a basic layout for a webpage using divs, unordered lists, and floats. I will be providing a screenshot of what the web layout will look like, as well as the code in html and css that designs that layout. Comments will be provided in each code snippet for html and css.

Objectives:

After studying the code and comments, you should be a little basic familiarity with how id selectors work and that they specify which styles the html code will be using from the css code, a little familiarity of why we had to use the float properties, what an unordered list looks like (in the code and visually), how the “clear” property works for floats, and how to make a really basic web layout.

Questions? Please leave a comment!

Desired Web Layout (with colors):

layout

HTML Code:

 

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="layout.css" />
    </head>
    <body>
        <div id="wrapper">
            <header> 
                Header
                <br />
                Header
                <br />
                Header
                <br />
                Header
                <br />
            </header>
            <nav>
                Navigation links go here.

                <ul>
                    <li>
                        <a href="#">Home</a>
                    </li>
                    <li>
                        <a href="#">Contact</a>
                    </li>
                    <li>
                        <a href="#">About</a>
                    </li>
                    <li>
                        <a href="#">Link #4</a>
                    </li>
                    <li>
                        <a href="#">Link #5</a>
                    </li>
                    <li>
                        <a href="#">Link #6</a>
                    </li>
                    <li>
                        <a href="#">Link #7</a>
                    </li>
                    <li>
                        <a href="#">Link #8</a>
                    </li>
                </ul>
            </nav>
            <div id="content">
                <p>Content goes here.</p>
            </div>
            <footer> 
                Footer
                <br />
                Footer
                <br />
                Footer
                <br />
                Footer
                <br />
            </footer>
        </div> <!-- Wrapper -->
    </body>
</html>

CSS Code:

Note: id selectors are always required to have the hashtag (#) before the name of the element in the css code.

 

body {
  background-color: yellow;
}

#wrapper {
  width: 80%;
  border-style: solid;
  border-color: black;
  border-width: medium;
  background-color: purple;
  margin-left: auto;
  margin-right: auto;
}

header {
  width: 100%;
  background-color: red;
}

nav {
  width: 30%;
  background-color: white;
  float: left;
  height: 400px;
}

#content {
  width: 70%;
  background-color: blue;
  float: right;
  height: 400px;
}

footer {
  clear: both;
  width: 100%;
  background-color: gray;
}

P.S:

You’re probably a motivated web developer who wants to freelance, blog, and/or be the best developer you can be. I feel many developers suffer from lack of clarity on their career/life, and poor time management and productivity practices. Without clarity and without the commitment to maximize your time, you don’t give yourself the ability to even work on your website projects and hone your coding skills with maximum efficiency.

To be the best coder, blogger, or freelancer you can be, it helps to master the non-technical aspects of entrepreneurship and personal growth. To begin building a solid foundation, I highly recommend that you consider getting my mentor’s free entrepreneurship book and training right now, where he shares his top 30+ tips that he followed in order to become a multi-million dollar entrepreneur in his 20s. I’ve read it, and as a blogger and web developer, it’s made a huge difference in my career outlook and my productivity! In addition, you may also find his productivity and time management master class useful to sign up for!

Remember that the book is free, so be sure to get it here now because I’m not sure if he’s planning to remove the book off the website! Obviously you have the choice, but I truly believe that you will learn some valuable lessons from it, like I have as a fellow blogger and developer. Please let me know if you have any questions, and I’d love to hear what you learn from the book!

teb-fb

 

Fanime and Computer Science

It’s probably been about three weeks or so since summer break started. I’ve had a pretty good one so far. I already accomplished a lot, I guess I could say. I’m watching more anime, I’ve been writing programs, I’m building a website, I’m blogging lol, and all at the same time I’ve been able to spend some time with friends and family.

Ash & Tifa
Me (Ash Ketchum) with a Tifa cosplayer

I’ll begin with Fanime. This year’s FanimeCon in San Jose was the first one I’ve ever been to, and I was pretty excited, and overwhelmed I suppose. I thought I was a real nerd, but seeing everyone at the convention in their awesome cosplays and such actually made me feel out of place. I hadn’t watched a whole lot of anime prior to the convention so my knowledge on everything  was pretty much non-existent compared to everyone else; there is no way I would be able to hold any kind of intelligent conversation with anyone there, but regardless I got used to the vibe after a while. I had my friends and cousin show up so we had fun walking around and seeing everything. I even had some fun watching the Stage Zero events; I kinda wish I participated in the cosplay drawing contest. By the way, I cosplayed as Ash Ketchum, and compared to all the cosplayers over at Fanime, I was pretty damn confident that my cosplay looked just as legit as everyone else’s!

Along with my going to Fanime and watching my friends graduate, I’ve written some programs already. Two of them were written in Java and they’re desktop apps that rename your directories/files in bunches for you (so you don’t have to do it manually for each directory/file), and one counts how many files of a certain format you have on your desktop. Now, especially for the first program, you might be wondering how useful that might be. Well, for those of you that watch anime, you have a lot of unnecessary junk written in the beginning and/or end of each file/direcotry name, right? That program is EXACTLY what it’s for. The only thing is, I have to modify my programs and turn them into interfaces rather than have them execute fully through text. After that’s accomplished, I hope I can publish them as apps that people can use so I can say that I’ve made some apps at some point in my life.

My Website
Current color scheme of our website

And together with those programs, I’ve been working on a website project for the past two weeks or so. This is the current look of the homepage, and as you can see there’s still a lot of work to be done. But it’s making progress! If any of you viewers would like to give any feedback on the color scheme and such, then feel free to comment (or those of you who link to here through my Facebook or Twitter, just message me :P). I would greatly appreciate a lot of feedback because in order for this website to be successful, it has to attract viewers (much like any other website). Also, ignore the black text please. That’s just there for testing purposes.

Having said that, it’s pretty much a website dedicated to video game reviews and guides written by me and a friend of mine, but there’s no content published as of right now. The website will even allow for gamers to interact with each other through forums and chat rooms, and watch video streams conducted by the administrators. At the moment we’re collaborating with each other to decide what designs, color schemes, features, etc etc would look good on our finished product. For individual projects, I’m developing the website (the design, and the client/server-side related stuff), and he is writing the content. Whenever this website is officially done, I’ll be sure to have a link to it on here. In the future, we may even allow for a section dedicated to anime discussion and reviews as well.

As far as updates go on the blog, be on the lookout for another anime review soon. I already made one for Angel Beats! as you probably saw, the next one will be a review on Boku wa Tomodachi ga Sukunai!