A Year and Five Years from Now

I’m taking an online course called CUST104: Business Communications by Saylor Academy.

In sub-unit 1.1 of the course, there are two introductory exercises. Here are the questions and my answers:

1. Write five words that express what you want to do and where you want to be a year from now. Take those five words and write a paragraph that clearly articulates your responses to both “what” and “where.”
  • study
  • freelance
  • love
  • Helsinki
  • Aalto University

I want to continue living in Helsinki and loving my wife. I want to have started my Computer Science studies at Aalto University and keep doing some freelance website projects on the side.

2. Think of five words that express what you want to do and where you want to be five years from now. Share your five words with your classmates and listen to their responses. What patterns do you observe in the responses? Write a paragraph that addresses at least one observation.
  • work on AI
  • raise a child
  • love my family
  • a smaller city
  • a workplace that fits my family life

I don’t have any classmates so I’ll just write about my own observations.

It’s good that I want to work on a challenging and important subject. I also want to make sure that my work doesn’t take too much attention away from things that are most important in life, which are family, love and happiness.

Things I Learned from Learn to Code HTML & CSS, Lesson 12

Here are some things I learned from Lesson 11: Organizing Data with Tables of Learn to Code HTML & CSS by Shay Howe.

HTML Coding Practices

Write Standards-Compliant Markup

HTML is a forgiving language that allows poor code to execute and render. However, this does not allow you to write poor code. Be sure to nest and close all elements correctly, to use IDs and classes appropriately, and to always validate your code.

Make Use of Semantic Elements

Carefully decide the proper semantic elements in your markup.

Use the Proper Document Structure

Use proper document structure, including the <!DOCTYPE html> doctype, and the <html>, <head>, and <body> elements.

Keep the Syntax Organized

A few quick rules:

  • Use lowercase letters within elements names, attributes, and values
  • Indent nested elements
  • Strictly use double quotes
  • Remove the forward slash at the end of self-closing elements
  • Omit the values on Boolean attributes

Use Practical ID & Class Values

The ID and class values need to be practical, relating to the content itself, not the style of the content.

For example, don’t use colors as class names, as you may want to change the colors in the future, and you’ll need to change both CSS and HTML to do that without causing confusion.

Use the Alternative Text Attribute on Images

Images should always include the alt attribute. Screen readers and other accessibility software rely on that.

The alt attribute value should be very descriptive of what the image contains. If the image doesn’t contain anything of relevance, the alt attribute should still be included and left blank so that the screen readers won’t read the name of the image.

If an image doesn’t have a meaningful value, it should be included as a CSS background image, not as an <img> element.

Separate Content from Style

Never use inline styles within HTML. Doing so creates pages that take longer to load, are difficult to maintain, and cause headaches for designers and developers. Instead, use external style sheets.

Avoid a Case of “Divitis”

Keep your code lean and reduce markup by tying multiple styles to a single element. Additionally, use HTML5 structural elements where suitable.

Continually Refactor Code

As websites and code bases grow, they tend to leave behind cruft. Remove old code and styles as necessary. Also, evaluate and refactor your code after you write it, looking for ways to condense it and make it more manageable.

CSS Coding Practices

Organize Code with Comments

Keep your styles organized in logical groups and provide comments noting what each group pertains to.

You can also use comments to build a table of contents at the top of the file.

Build Proficient Selectors

Use short and direct selectors. Nest them only two to three levels deep, and remove as many location-based qualifying selectors as possible. Otherwise the selectors are likely to break the cascade of the CSS files.

Use Specific Classes When Necessary

Replace long and specific selector chains with a single class. It allows the code to render faster and makes it more manageable.

Use Shorthand Properties & Values

When you need to set multiple margins around an element, for example, use the margin shorthand property.

If you’re only targeting one side of the element, however, avoid the shorthand to ensure that other margin properties are not overwritten.

Use Shorthand Hexadecimal Color Values

When possible, use the three-character shorthand hexadecimal color value, and always use lowercase characters within your color values. The idea is to remain consistent, prevent confusion, and embrace the syntax of the language.

Drop Units from Zero Values

Adding the unit is unnecessary and provides no additional value.

Group & Align Vendor Prefixes

To keep the code easy to read and modify, group and indent vendor prefixes so that the property names and their values stack vertically.

Modularize Styles for Reuse

If different elements share the same style, use a common class with a name that suits them all.

Things I Learned from Learn to Code HTML & CSS, Lesson 11

Here are some things I learned from Lesson 11: Organizing Data with Tables of Learn to Code HTML & CSS by Shay Howe.

When HTML was being developed, CSS was not widely supported, so websites were built primarily with tables.

Today tables are used for organizing data, like they should be.

Creating a Table

Table Header

A <th> element’s scope attribute helps to identify what content a table header relates to. Possible values are col, row, colgroup, and rowgroup. This is especially useful for people using screen readers and other assistive technologies.

Table Structure

Table Caption

The <caption> element provides a caption or title for a table. It must come immediately after the opening <table> tag, and it is positioned at the top of a table by default.

Table Head, Body, & Foot

The table head element, <thead>, wraps the heading row or rows of a table to denote the head. It should be placed at the top of a table, after any <caption> element and before any <tbody> element.

Originally the <tfoot> element had to come immediately after the <thead> element, but HTML5 allows any order, as long as they are never parent elements of one another. The <tbody> element should contain the primary data within a table, while the <tfoot> element contains data that outlines the contents of a table.

Table Borders

Border Collapse Property

There are three values for the border-collapse property: collapse, separate (default), and inherit. The collapse value condenses the borders into one, choosing the table cell as the primary border.

Border Spacing Property

As the border-collapse property with the separate value allows borders to be stacked up against one another, the border-spacing property can determine how much space, if any, appears between the borders.

Additionally, the border-spacing property may accept two length values: the first value for horizontal spacing and the second value for vertical spacing.

Adding Borders to Rows

Borders cannot be applied to <tr> elements or table structural elements.

It happens like this: set the table’s border-collapse value to collapse, and then add a bottom border to each table cell, regardless of whether it’s a <th> or <td> element. You can remove the bottom border from the cells within the last row of the table by using the :last-child pseudo-class selector. If the table is using the structural elements, make sure to prequalify the last row as being within the <tfoot> element.

Table Striping

You can use the :nth-child pseudo-class selector with an even or odd argument to select every other <tr> element for custom styling.

If your <td> elements include borders while the <th> elements don’t, you need to set the table’s border-collapse property to separate and the border-spacing property to 0. In addition, you need to set each cell’s borders only once, for example by using the border-right and border-bottom properties on the cells and the border-left property on the cells in the first column.

Otherwise with the border-collapse property set to collapse, the borders of the <td> elements would make the body of the table wider than the head.

Aligning Text

The vertical-align property works only with inline and table-cell elements. It won’t work for block, inline-block, or any other element levels. [JN: I’ve used vertical-align for inline-block elements succesfully, so this is a little confusing. If you know why it works, please leave a comment.]

The vertical-align values of top, middle, and bottom vertically position the text in relation to the table cell, for table-cell elements, or to the closest parent element, for inline-level elements.

Completely Styled Table

You can use display: block to force stuff on its own row within a table cell.

In Practice

The :only-of-type pseudo-class selector selects an element if it’s the only element of its type within a parent element.