Getting Started with HTML Structure and Responsive Design

Hello, future coders! Today, we're embarking on a voyage through the cosmos of web development, guided by the spaceship of HTML and venturing through the uncharted territories of Responsive Design. Hang on tight; this journey is going to be packed with knowledge and practical examples!

Semantic Markup

Semantic HTML tags provide meaning to the sections they encompass, thus helping search engines determine the nature of the content and thereby enhancing your Search Engine Optimization efforts. Descriptive tags such as header, footer, main, section, article, etc., make your HTML comprehensible to both human readers and web spiders.

Consider the skeletal structure of a webpage depicted below. Here, the semantic tags — header, main, and footer — lucidly demarcate the different sections of the webpage.

<body>
  <header>
    <h1>Welcome to my profile!</h1>
  </header>
  
  <main>
    <section>
      <h2>About Me</h2>
      <p>Hi! I am an aspiring web developer.</p>
    </section>
  
    <section>
      <h2>My Skills</h2>
      <p>I love coding in HTML, CSS, and JavaScript.</p>
    </section>
  </main>
  
  <footer>
    <p>Thanks for visiting my profile!</p>
  </footer>
</body>

In this example, the header serves as the topmost section of the page, main is where the central content is located, and each section within the main encapsulates different parts of the main content. The footer resides at the bottom, providing additional or meta-information about the webpage.

Embracing Semantic Markup for Consistent Layout Across Screens

Semantic markup is the use of HTML markup to reinforce the meaning of the information in webpages rather than merely to define its presentation or look. Semantic HTML tags provide beneficial effects on the accessibility, adaptability, and overall performance of your websites.

"But why does it matter in responsive design?" you might ask.

To answer this question, consider a city map. The map helps you understand locations and directions, where to find landmarks, restaurants, parks, and so forth. It gives meaning to the layout of the city.

Semantic HTML serves a similar purpose for your webpage. It acts as a guide for the browser displaying your webpage, assisting it in understanding the structure and offering suitable styles and configurations for different elements. While non-semantic HTML tags like <div> and <span> tell nothing about its content, semantic tags like <header>, <nav>, <section>, <article>, <aside> and <footer> describe precisely what kind of information you can expect within them. This ensures a consistent cross-screen layout as the browser knows how to correctly display these elements regardless of the screen size.

Have a look at this example:

<body>
  <header>
    <h1>Welcome to my Website!</h1>
  </header>
  
  <nav>
    <a href="#contact">Contact</a>
    <a href="#about">About</a>
  </nav>
  
  <main>
    <article>
      <h2>HTML and CSS Basics</h2>
      <p>HTML and CSS are the foundational technologies for building websites.</p>
    </article>
    
    <aside>
      <h4>Note</h4>
      <p>HTML structures the webpage, while CSS styles it.</p>
    </aside>
  </main>
  
  <footer>
    <p>Thank You for Visiting!</p>
  </footer>
</body>

In the above snippet, each HTML element plays a particular role. The <header> holds website's title, <nav> is for navigation links, <main> for the main content of the webpage, <article> for individual content block, <aside> for side content, and <footer> for the footer.

Using these semantic tags ensures the browser knows what each section is and how to display it relative to other sections, even on different screens. This makes your webpage layout consistent across a variety of devices making your web page truly responsive.

Remember, using semantic markup in HTML is not only a good practice but a journey towards creating more accessible, discoverable, and robust web pages. So, buckle up and start implementing these in your code today! 🚀

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal