HTML Basics: Style and Structure

HTML Basics: Style and Structure

Style and Structure Guidelines
clear structure for your HTML documents makes them easy to read, easy to follow, and easy to modify.

If you disappeared tomorrow and other people had to come in to work on your HTML files, could they figure out what you’ve been doing . . . or would it be like looking at a big messy glob of tags and text? It’s easy to end up with spaghetti code. That’s why one of the first steps, in learning how to create Web pages, is to learn some simple structural guidelines.

File Creation Guidelines
One of the first steps, in learning how to create Web pages, is to learn some simple structural guidelines. Following a few simple style and structure guides makes your site both consistent and legible. There is no single “right” style or structure to use (as long as you are using the tags correctly of course!). What is most important isn’t that you follow our recommendations?it is that you are consistent in your own files, that way:

  • When you’re building a new page and troubleshooting a problem, a clean style makes it easy to both see what you’ve done and make changes.
  • When you come in to edit a page three months after you created it, you can quickly see what you did and how you did it, without having to recreate your thought pattern or walk through the file character by character.
  • If someone else needs to modify it they can understand your code and make the necessary changes.
Tip #1: To Each Its Own Line

In general, keep each tag on a separate line. This makes it easy to see what is going on. Codes don’t become lost in a morass of type.

The exceptions to this are: in-body tags, such as making a word bold, and the line break command (
). The logical place for both of these are with the text they define.

Ask yourself: in which of these code examples is it easier to find the errors (and there are several errors!)?

In this one?

Getting Your Own

Widgets offers many, manythe great things including:

    wigglers

  • jumpers
  • creepy-crawlies

.To place an order call our 1-800 number.

Or in this one?

Getting Your Own



Widgets offers many, manythe great things including:


    wigglers

  • jumpers
  • creepy-crawlies



To place an order call our 1-800 number.

Here are the errors?did you see them all?

Tip #2: Use Comments

You can add comments to your file. The comments will be ignored by HTML but they can help you add information about your file or what a piece of code is doing.

The code tag looks like this:

Everything between the opening is invisible to the web browser.

Tip #3: Lists Should Be Legible

Lists, especially nested lists, are hotbeds for accidental errors. Keeping lists legible makes using them much easier.

  • Indent nested lists. Use the tab key to make a quick and easy indent. Remember, HTML ignores multiple spaces, so indenting in your file won’t affect the way the page displays.
  • Keep tags on separate lines.
  • Consider adding an extra return to “pull-out” lists visually.

Both of those examples will display exactly the same on a Web browser?but which do you find easier to read and edit?

This one?

Halloween gifts:

  • wigglers
    • corpse white
    • choked blue
  • jumpers
  • creepy-crawlies

Easter gifts:

  • fuzzies
    • chickie yellow
    • bunny beige
  • floppies
  • cottontails

Or this one?


Halloween gifts:


  • wigglers
         

           

    • corpse white
           
    • choked blue
           


  • jumpers
  • creepy-crawlies



Easter gifts:


  • fuzzies
         

           

    • chickie yellow
           
    • bunny beige
           


  • floppies
  • cottontails

Errors
Things That Are Wrong:

  • The mistyped list tag ( instead of
  • )
  • The mistyped paragraph tag ( instead of

    )

  • There is an extra “the” in the phrase “Widgets offers many, many (the) great things”

File Directory Guidelines
Your Web site is made of many individual files. In addition to organizing the content inside each file consistently, it is a good idea to save the files in some logical locations with logical and consistent names. A good directory structure makes it easier to transfer files to and from your site and simplifies site maintenance.

Here’s a few guidelines to help you get started:

Structure Tip #1: Keep Related Files Together

Put related files into the same directory. For example, if you are making a home page about how you are an athletic star, you might have a baseball directory, a hockey directory, and a basketball directory. All the files about you and baseball go into the baseball directory, the one about hockey into the hockey directory, and the ones about basketball into the basketball directory.

Within each directory, put the same types of files together in subdirectories. For example, you might make an images subdirectory in your baseball directory and put all your jpegs and gifs of you rounding the bases there. In the hockey directory there will also be an images folder containing all your hockey images.

Structure Tip #2: Put Common Files in a Top-level Directory

Put elements that are used across the entire site in a top level directory, so you only need one copy of each file. For example, you might have a top-level directory called siteimages, which contains your logo and your smiling face.

Structure Tip #3: Create Index Files

Create a file called index.html and save it in the top level index. This file should contain the opening page of your site. This is the page that will load into a browser by default. When readers type http://www.bigego.com, this opening page will load.

Create a file called index.html within each of your subdirectories. Each of these index files will be the opening page for its respective section. When readers type http://www.bigego.com/baseball, your baseball index will load.

For example, If your main Web directory is called “public_html” you might have a directory structure like this:

public_html (main html directory)

     images (contains the site-wide gifs and jpegs)
     index.html (the opening page)

     baseball (a subdirectory)
          index.html (main page of the baseball section)
          images (contains baseball-related gifs and jpgs)
          sounds (this contains baseball-related sound files)

     hockey (a subdirectory)
          index.html (main page of the hockey section)
          images (contains hockey-related gifs and jpgs)
          sounds (contains hockey-related sound files)

     basketball (a subdirectory)
          index.html (main page of the basketball section)
          images (contains basketball-related gifs and jpgs)
          sounds (contains basketball-related sound files)

Each of the subdirectories holds files of the appropriate file type and category of files. This type of structure makes it easier to keep track of your site as it grows. If you put a structure in place like this at the beginning, then you won’t be faced with a cataloging mess later.

devx-admin

devx-admin

Share the Post:
Apple Tech

Apple’s Search Engine Disruptor Brewing?

As the fourth quarter of 2023 kicks off, the technology sphere is abuzz with assorted news and advancements. Global stocks exhibit mixed results, whereas cryptocurrency

Revolutionary Job Market

AI is Reshaping the Tech Job Market

The tech industry is facing significant layoffs in 2023, with over 224,503 workers in the U.S losing their jobs. However, experts maintain that job security

Foreign Relations

US-China Trade War: Who’s Winning?

The August 2023 visit of Gina Raimondo, the U.S. Secretary of Commerce, to China demonstrated the progress being made in dialogue between the two nations.

Pandemic Recovery

Conquering Pandemic Supply Chain Struggles

The worldwide coronavirus pandemic has underscored supply chain challenges that resulted in billions of dollars in losses for automakers in 2021. Consequently, several firms are

Game Changer

How ChatGPT is Changing the Game

The AI-powered tool ChatGPT has taken the computing world by storm, receiving high praise from experts like Brex design lead, Pietro Schirano. Developed by OpenAI,

Apple Tech

Apple’s Search Engine Disruptor Brewing?

As the fourth quarter of 2023 kicks off, the technology sphere is abuzz with assorted news and advancements. Global stocks exhibit mixed results, whereas cryptocurrency tokens have seen a substantial

GlobalFoundries Titan

GlobalFoundries: Semiconductor Industry Titan

GlobalFoundries, a company that might not be a household name but has managed to make enormous strides in its relatively short 14-year history. As the third-largest semiconductor foundry in the

Revolutionary Job Market

AI is Reshaping the Tech Job Market

The tech industry is facing significant layoffs in 2023, with over 224,503 workers in the U.S losing their jobs. However, experts maintain that job security in the sector remains strong.

Foreign Relations

US-China Trade War: Who’s Winning?

The August 2023 visit of Gina Raimondo, the U.S. Secretary of Commerce, to China demonstrated the progress being made in dialogue between the two nations. However, the United States’ stance

Pandemic Recovery

Conquering Pandemic Supply Chain Struggles

The worldwide coronavirus pandemic has underscored supply chain challenges that resulted in billions of dollars in losses for automakers in 2021. Consequently, several firms are now contemplating constructing domestic manufacturing

Game Changer

How ChatGPT is Changing the Game

The AI-powered tool ChatGPT has taken the computing world by storm, receiving high praise from experts like Brex design lead, Pietro Schirano. Developed by OpenAI, ChatGPT is known for its

Future of Cybersecurity

Cybersecurity Battles: Lapsus$ Era Unfolds

In 2023, the cybersecurity field faces significant challenges due to the continuous transformation of threats and the increasing abilities of hackers. A prime example of this is the group of

Apple's AI Future

Inside Apple’s AI Expansion Plans

Rather than following the widespread pattern of job cuts in the tech sector, Apple’s CEO Tim Cook disclosed plans to increase the company’s UK workforce. The main area of focus

AI Finance

AI Stocks to Watch

As investor interest in artificial intelligence (AI) grows, many companies are highlighting their AI product plans. However, discovering AI stocks that already generate revenue from generative AI, such as OpenAI,

Web App Security

Web Application Supply Chain Security

Today’s web applications depend on a wide array of third-party components and open-source tools to function effectively. This reliance on external resources poses significant security risks, as malicious actors can

Thrilling Battle

Thrilling Battle: Germany Versus Huawei

The German interior ministry has put forward suggestions that would oblige telecommunications operators to decrease their reliance on equipment manufactured by Chinese firms Huawei and ZTE. This development comes after

iPhone 15 Unveiling

The iPhone 15’s Secrets and Surprises

As we dive into the most frequently asked questions and intriguing features, let us reiterate that the iPhone 15 brings substantial advancements in technology and design compared to its predecessors.

Chip Overcoming

iPhone 15 Pro Max: Overcoming Chip Setbacks

Apple recently faced a significant challenge in the development of a key component for its latest iPhone series, the iPhone 15 Pro Max, which was unveiled just a week ago.

Performance Camera

iPhone 15: Performance, Camera, Battery

Apple’s highly anticipated iPhone 15 has finally hit the market, sending ripples of excitement across the tech industry. For those considering upgrading to this new model, three essential features come

Battery Breakthrough

Electric Vehicle Battery Breakthrough

The prices of lithium-ion batteries have seen a considerable reduction, with the cost per kilowatt-hour dipping under $100 for the first occasion in two years, as reported by energy analytics

Economy Act Soars

Virginia’s Clean Economy Act Soars Ahead

Virginia has made significant strides towards achieving its short-term carbon-free objectives as outlined in the Clean Economy Act of 2020. Currently, about 44,000 megawatts (MW) of wind, solar, and energy

Renewable Storage Innovation

Innovative Energy Storage Solutions

The Department of Energy recently revealed a significant investment of $325 million in advanced battery technologies to store excess renewable energy produced by solar and wind sources. This funding will

Renesas Tech Revolution

Revolutionizing India’s Tech Sector with Renesas

Tushar Sharma, a semiconductor engineer at Renesas Electronics, met with Indian Prime Minister Narendra Modi to discuss the company’s support for India’s “Make in India” initiative. This initiative focuses on

Development Project

Thrilling East Windsor Mixed-Use Development

Real estate developer James Cormier, in collaboration with a partnership, has purchased 137 acres of land in Connecticut for $1.15 million with the intention of constructing residential and commercial buildings.

USA Companies

Top Software Development Companies in USA

Navigating the tech landscape to find the right partner is crucial yet challenging. This article offers a comparative glimpse into the top software development companies in the USA. Through a

Software Development

Top Software Development Companies

Looking for the best in software development? Our list of Top Software Development Companies is your gateway to finding the right tech partner. Dive in and explore the leaders in

India Web Development

Top Web Development Companies in India

In the digital race, the right web development partner is your winning edge. Dive into our curated list of top web development companies in India, and kickstart your journey to

USA Web Development

Top Web Development Companies in USA

Looking for the best web development companies in the USA? We’ve got you covered! Check out our top 10 picks to find the right partner for your online project. Your

Clean Energy Adoption

Inside Michigan’s Clean Energy Revolution

Democratic state legislators in Michigan continue to discuss and debate clean energy legislation in the hopes of establishing a comprehensive clean energy strategy for the state. A Senate committee meeting

Chips Act Revolution

European Chips Act: What is it?

In response to the intensifying worldwide technology competition, Europe has unveiled the long-awaited European Chips Act. This daring legislative proposal aims to fortify Europe’s semiconductor supply chain and enhance its