HTML/CSS Sample: Text Hello

HTML/CSS TASK:

Create new HTML document which shows a heading with text “Hello” followed by a paragraph with text “This is my first text”. Use “First Title” for a page title. Add CSS code to the page, specifying the background color of page to be black, heading text color to be red, and paragraph text color to be white. Finally, make sure that the paragraph uses Arial font type with font size being equal to 25 pixels, and the text being written in italics.

SOLUTION:

In this sample we should start with creating a basic HTML document first (can be a txt document with extension being changed to *.html later). The basic pair of tags:

<HTML> </HTML>

These must be joined with tags for head and body sections of HTML:

<HTML>
	<HEAD> </HEAD>
	<BODY> </BODY>
</HTML>

We use head section to insert the page title, while the body section is used to house the rest of our text sections (the heading and the paragraph). Since the heading size is not specified, we use the largest one (H1):

<HTML>
	<HEAD>
		<TITLE>First Title</TITLE>
	</HEAD>
	<BODY>
		<H1>Hello</H1>
		<P>This is my first text</P>
	</BODY>
</HTML>

Right now when we run our page in the browser, we can see the text showing up, but we still lack the CSS code for specifying the style parameters. While it can be housed in an external file as well, in this example for the purposes of simplicity we will write it right in the style section:

<HTML>
	<HEAD>
		<TITLE>First Title</TITLE>
	</HEAD>
	<STYLE>
	</STYLE>
	<BODY>
		<H1>Hello</H1>
		<P>This is my first text</P>
	</BODY>
</HTML>

When it comes to style, we will need to specify it separately for different parts of the document – in our case those are called body (corresponding to the whole page), h1 (corresponding to headings of 1st type) and p (corresponding to paragraphs):

<HTML>
	<HEAD>
		<TITLE>First Title</TITLE>
	</HEAD>
	<STYLE>
	body { }
	h1 { }
	p { }
	</STYLE>
	<BODY>
		<H1>Hello</H1>
		<P>This is my first text</P>
	</BODY>
</HTML>

Next, we must insert the actual parameters. Let’s start with color. For styles, color can be specified in hex form (i.e. #FF000) or used color name (i.e. red). Let’s use the latter option for adding colors:

<HTML>
	<HEAD>
		<TITLE>First Title</TITLE>
	</HEAD>
	<STYLE>
	body { 
		color: black;
	}

	h1 { 
		color: red;
	}

	p { 
		color: white;
	}
	</STYLE>
	<BODY>
		<H1>Hello</H1>
		<P>This is my first text</P>
	</BODY>
</HTML>

Once we check this, we can see that background is still white. That’s because in case of background, we need to use a parameter called “background-color” instead. Similarly, for specifying font, simply using “font” would not work, but “font-family”, “font-size” and “font-style” would do. The final result would look like this:

<HTML>
   <HEAD>
      		<TITLE>First Title</TITLE>
   </HEAD>
	<STYLE>
	body {
		background-color: black;
	}

	h1 {
		color: red;
	}

	p {
		color: white;
		font-family: "Arial";
		font-size: 25px;
		font-style: italic;
	}
	</STYLE>
	<BODY>
	   <H1>Hello</H1>
	   <P>This is my first text</P> 
	</BODY>
</HTML>

This HTML/CSS sample was accomplished by our IT expert in accordance with our requirements. If you want your task to be completed in the same way – with proper explanations and examples – feel free to contact us whenever needed and get qualified help. Specify as much instructions as you can and we will do our best to make your studies easier.

You may also be interested on how to create a Readme file explained in details.

Leave a Reply

Your email address will not be published. Required fields are marked *

Customer testimonials

Submit your instructions to the experts without charge.