HTML and CSS

by Cameron Bolyard

HTML

HTML (HyperText Markup Language) is an extension of the XML language, which we've seen used in writing our pom.xml's for Maven. XML (and by extention HTML) uses a format of tags in order to organize its elements. There are typically two kinds of tags in html. Generic ones that can be flexible towards any kind of text: <div> for division, <span> for a span, etc. And there are tags ("semantic tags") designed to be as straightforward as possible, featuring options such as <p> for paragraph, <ol> and <ul> for ordered and unordered list, <code> for code, etc.

HTML was originally specified and then written in the late 1990s by Tim Berners-Lee, now known as "the inventor of the World Wide Web, HTML, the URL system, and HTTP." The first area that Berners-Lee listed as a use for HTML was an Encyclopedia.

W3C, CC BY 3.0, via Wikimedia Commons

CSS

CSS (Cascading Style Sheets) is HTML's partner in crime. You'll almost never see an HTML file without CSS being involved in some way. CSS featues the same brackets and semicolons we've known and loved from Java. Similar to the way that functions are written, CSS has the selector (element, class, ID, etc.) first, then {} wrapping the style made. Inside these brackets the styles are sent, with the line ending with a semicolon.

There are three ways that CSS is typically used in tandem with HTML:

  • Inline: <p style="color: #FFFFFF"></p>
  • In File:
    <head>
      <!-- OMITTED CODE -->
    
      <style>
        p {
          color: #FFFFFF;
        }
      </style>
    </head>
  • External File: <link rel="stylesheet" href="styles.css"/>