How to Create and Validate Your Own HTML and CSS Templates


When I write a piece of writing–or any web page, for that count number–I like first of all primary HTML, XHTML, and CSS files I understand include valid code. After studying this education, you’ll be able to use this technique, too. There are two styles of fundamental, requirements-based files that I use to write web pages. The first has a Document Type Definition(DTD) of XHTML 1.Zero Transitional, just like WordPress uses. The 2nd is a simple HTML file with a Document Type Definition(DTD) of HTML four.01 Transitional. These definitions tell the browser which specification the record uses. For instance, the DTD would tell a browser if the record was HTML or XHTML. The DTD is the primary line of code on an internet web page.


The syntax guidelines for HTML and XHTML are exclusive in some approaches. It would help if you used the proper syntax for the DTD you use, or your code will no longer skip at W3C. This is so even though the browser you use might display your web page as expected: browsers are very forgiving concerning non-fashionable code. I use the HTML 4.01 Transitional DTD for the content material on my website because I am secure with its syntax. The best manner to ensure which you are starting with a requirements-based totally net page is to first reproduction a known suitable skeletal net page and paste it right into a simple text editor. Next, keep the code as a text document with the “.Text” extension. You could call the file my-html-template.Txt. You can also paste the code into the W3C Markup Validation Service to check that it’s far as much as snuff: if the code passes the validator “in the green,” you know your code is right. Simple skeletal web pages can be determined at W3 Schools. Other code, together with the DTD for HTML and XHTML, can also be located there.

It is very commonplace to find that online web pages fail W3C validation with many errors. Sometimes, the wrong DTD is specified for a web page; at different times, the failure is because of using not-well-known or deprecated code. If you begin with a legitimate, simple template and accurate any validation mistakes that show up, your pages will constantly be “inside the inexperienced” when posted to the Web. Once you’ve got a valid basic template, you may add your content between the body tags and additional code between the head tags.

Normally, I do now not use hard carriage returns inside a paragraph. The editors I use all have a “word wrap” feature that enables me to see all the textual content I write without applying the horizontal scroll bar. The actual line period of the posted content could be determined later whilst the web page show is styled. I use a tough carriage return after the remaining sentence of a paragraph and upload an extra one between paragraphs. Hard returns can also be delivered to the additional area between other factors, together with the photograph code.

If you’ve added content material to the my-html-template.Txt report, store it again with a “.Html” report extension. You can then open it in a browser. What you may see is that all of the content material runs together. That is due to the fact browsers look for line smash tags and not carriage returns. You can repair this by discovering and replacing it with your editor: discover each carriage return and replace it with a wreck tag. When you open the HTML report again, the content material’s numerous components can be neat and tidy however not very pretty. CSS styling will restoration this.

If you’re simply “dropping” the content between the frame tags into a visual editor on the internet, together with a WordPress editor or the article content material container at EzineArticles, you oughtn’t fear about the road breaks as they’ll be added to the HTML code for you. Copy and paste the CSS code below into your text editor. Save it as “my-template. CSS” within the identical folder in that you saved your HTML template file.


  • heritage: #fffef2;
  • color: black;
  • line-height: regular;
  • margin: three% 25% three% 25%;
  • min-width: 400px;

The hyperlink meta tag buddies a CSS document with the HTML document. Copy and paste the hyperlink tag proven below among the top tags inside the my-html-template.Txt record you saved. Replace the bracket characters with “, respectively.

[link title=”Template Style Sheet” rel=”stylesheet” href=”my-template.Css”type=”text/CSS”]

If you’ve delivered a few contents in your my-html-template.Txt document, while you now open the record in a browser, you may begin to see some pretty best formatting. The web page content is now centered in approximately the center half of the web page, there may be a pleasant heritage color, and the textual content is Verdana. This is all due to the specs in the CSS code for “body.”The “body” code determines the general appearance of the web page. You also can validate your CSS code. W3C has a CSS code validator. Just reproduction the CSS code and paste it in the validator’s textual content field and click on the “Check” button. You will discover that the code above passes “in the green,” as it should.


To use show formatting, the content material to receive the formatting ought to be identified. Content may be bracketed with HTML tags, which contain names that reference styling definitions inside the CSS document. Examples of these tags are “div” and “span.” When a browser encounters an HTML tag and reveals a call reference, it appears inside the CSS record for the styling and then applies it to the web page shows. If there may be no styling referenced within the HTML tags, the browser will use its defaults for the display.

W3 Schools has complete data and tutorials about CSS.

Building your own (X)HTML and CSS templates–and then putting them through the W3C validators–is a great way to ensure that your internet pages will continually be requirements-based. You don’t need a highly-priced web-improvement software package to develop your templates; you may use a simple text editor. Use the textual content editor to build the web page structure and add the content. Use CSS to fashion the display of the content material. If you publish your content online, you will probably be capable of dropping the content material from your textual content record (between the frame tags) right into the editor’s text field without any modifications. If you need to view your file in a browser as you create it, you would possibly upload break tags between content material factors, save the file with a “.Html” extension. If you validate your net pages as you create them, you can continually make sure that when they’re published online, they may validate “inside the green.”

Previous articleHow An Employee Time Clock App Can Improve Workplace Morale
Next articleHow to Find the Best WordPress Theme for Your Business
Pop culture fanatic. Tv scholar. Coffeeaholic. Zombie maven. Food advocate. Analyst. Enthusiastic about buying and selling cannibalism in Pensacola, FL. Had some great experience licensing robotic shrimp in Phoenix, AZ. Earned praise for analyzing accordians for farmers. Enthusiastic about training lint in Libya. Earned praised for my work researching wooden tops in Orlando, FL. Crossed the country exporting the elderly in Jacksonville, FL.