EIT Module 5
EIT Module 5
MODULE 5
Computer Graphics
Computer graphics is a branch of computer science that uses computer technology
to produce and manipulate visual representations.
1. Presentation of text
2. Construction of graphs and charts
3. Development of graphical user interfaces (GUIs)
4. Manipulation of photographs
5. Production of video games
6. Creation of animated motion pictures
With digital cameras, image manipulation software has become very popular.
Such software can remove blemishes, fix red-eye, and combine parts of
different photos to create new images.
These manipulations often produce images that do not reflect reality.
Motion picture and TV industries use similar techniques for special effects,
such as removing wires, overlaying images, and altering recorded action.
The shift from analog film to digital images in these industries was strongly
motivated by these editing possibilities.
Software tools (like Microsoft Paint) allow creation of 2D drawings with
functions such as drawing dots and lines, inserting geometric shapes, filling
regions with colors, and cut-and-paste.
More advanced 2D software supports layers, gradients, textures, and digital
painting.2D graphics focuses on producing images by converting shapes into
pixels.
Once the portion of the scene that projects into the image window is identified,
the appearance of each pixel in the final image is computed.
This pixel-by-pixel process can be computationally complex because it requires
determining how the objects in the scene interact with light.
A hard, shiny surface in bright light should be rendered differently than a soft,
transparent surface in indirect light.
The rendering process borrows heavily from fields including material science
and physics.
Determining the appearance of one object often requires knowledge about other
objects in the scene.
The object may be in the shadow of another object, or the object may be a
mirror whose appearance is essentially that of another object.
As the appearance of each pixel is determined, the results are stored collectively
as a bit map representation of the image in a storage area called the frame
buffer.
The frame buffer may be an area of main memory or, in the case of hardware
designed specifically for graphics applications, it may be a block of special-
purpose memory circuitry.
Finally, the image stored in the frame buffer is either displayed for viewing or
transferred to more permanent storage for later display.
If the image is being produced for use in a motion picture, it may be stored and
perhaps even modified before final presentation.
10.3 Modeling
Based on this formula, we can establish equations for lines of latitude and lon gitude on
the sphere, identify the points where these lines intersect, and then use these points as the
vertices of a polygonal mesh.
Similar techniques can be applied to other traditional geometric shapes, and this is why
characters in less-expensive computer-generated animations often appear to be pieced
together from such structures as spheres, cylinders, and cones.
Starting with a single triangle, identify the midpoints of the triangle’s edges
(Figure 10.4a). Then, connect these midpoints to form a total of four smaller
triangles (Figure 10.4b). Now, while holding the original triangle’s vertices fixed,
move the midpoints in three-dimensional space (allowing the triangle’s edge lines
to stretch or contract), thus distorting the triangular shapes (Figure 10.4c). Repeat
this process with each of the smaller tri angles ( Figure 10.4d), and continue
repeating the process until the desired detail is obtained.
Another method of constructing procedural models is to simulate the underly ing structure
of an object as a large collection of particles.
Such models are called particle systems. Usually particle systems apply certain
predefined rules to move the particles in the system, perhaps in a manner reminiscent of
molecular interactions, to produce the desired shape.
As an example, particle systems have been used to produce an animation of sloshing
water as we will see later in our discussion of animation. (Imagine a bucket of water
modeled as a bucket of mar bles. As the bucket rocks, the marbles tumble around,
Surface Characteristics
Once the objects in a scene are adequately described and digitally encoded, they
are each assigned a location, size, and an orientation within the scene.
This collection of information is linked to form a data structure called a scene
graph.
The scene graph also contains links to special objects representing light sources
and a particular object representing the camera.
The location, orientation, and focal properties of the camera are recorded in the
scene graph.
A scene graph is analogous to a studio setup in traditional photography—it
contains the camera, lights, props, and background scenery in proper places.
The difference: traditional photography contains physical objects, while a
scene graph contains digitally encoded representations.
In short, a scene graph describes a virtual world.
The positioning of the camera has many repercussions—foreground objects
require more detail than background objects, and this distinction depends on the
camera position.
If the camera is moved, the object models may need to be adjusted dynamically
between different “photographs.”
determining surface details, and simulating light effects—tasks that are largely
independent of the application.
10.4 Rendering
Depending on the material properties of an object, light striking its surface may be absorbed,
bounce off the surface as reflected light, or pass through the surface (and be bent) as refracted
light.
Reflection
Let us consider a ray of light that is reflected off a flat opaque [Link] ray
arrives traveling in a straight line and strikes the surface at an angle called the
incidence angle.
The angle at which the ray is reflected is identical to the incidence [Link]
shown in Figure 10.5, these angles are measured relative to a line perpendicular
(or normal) to the surface.
A line normal to a surface is often referred to as simply “the normal” as in “The
incidence angle is measured relative to the normal.”
The incoming ray, the reflected ray, and the normal all lie in the same plane.
If a surface is smooth, parallel light rays (such as those arriving from the same
light source) that strike the surface in the same area will be reflected in
essentially the same direction and travel away from the object as parallel
[Link] reflected light is called specular light.
Note that specular light can be observed only when the orientation of the
surface and the light source causes the light to be reflected in the viewer’s
direction.
Thus, it normally appears as bright highlights on a [Link], because
specular light has minimal contact with the surface, it tends to portray the color
of the original light source.
Unlike specular light, diffuse light is visible within a wide range of directions.
Because it tends to have prolonged contact with the surface, diffuse light is
more susceptible to the absorption properties of the [Link], diffuse
light tends to portray the color of the object.
Figure 10.6 presents a ball that is illuminated by a single light [Link] bright
highlight on the ball is produced by specular light.
The rest of the hemisphere facing the light source is seen by means of diffuse
[Link] hemisphere facing away from the primary light source is not visible
by means of light being reflected directly from that source.
The ability to see this portion of the ball is due to ambient light, which is “stray”
or scattered light that is not associated with any particular source or direction.
Portions of surfaces illuminated by ambient light often appear as a uniform
dark color.
Most surfaces reflect both specular and diffuse [Link] characteristics of the
surface determine the proportion of each.
Smooth surfaces appear shiny because they reflect more specular light than
diffuse [Link] surfaces appear dull because they reflect more diffuse light
Refraction
Now consider light striking an object that is transparent rather than [Link]
this case light rays pass through the object rather than bounce off its surface.
As the rays penetrate the surface, their direction is altered—a phenomenon
called refraction (Figure 10.7).The degree of refraction is determined by the
refractive index of the materials involved.
The refractive index is related to the density of the [Link] materials
tend to have a higher refractive index than less dense materials.
As a light ray passes into a material with a higher refractive index (such as
passing from air into water), it bends toward the normal at the point of entry.
If it passes into a material with a lower refractive index, it bends away from
the normal.
Let us now focus on the process of producing an image from a scene graph.
Our approach for now is to follow the techniques used in most interactive video
game systems.
Collectively, these techniques form a well-established paradigm known as the
rendering pipeline.
We will consider some of the pros and cons of this approach at the end of this
section and explore two alternatives in the following section.
For now it is helpful to note that the rendering pipeline deals with opaque
objects and thus refraction is not an issue.
Moreover, it ignores interactions between objects so that, for now, we will not
be concerned with mirrors and shadows.
The rendering pipeline begins by identifying the region in a three-dimensional
scene that contains the objects (or parts of objects) that can be “seen” by the
camera.
This region, called the view volume, is the space within the pyramid defined by
straight lines extending from the center of projection through the corners of the
image window (Figure 10.8).
Once the view volume is identified, the task is to discard from consideration
those objects or parts of objects that do not intersect the view volume.
The projection of portions of the scene outside the view volume will fall outside
the image window and therefore not appear in the final image.
The first step is to discard all those objects that are totally outside the view
volume.
To streamline this process, a scene graph may be organized in a tree structure in
which objects in different regions of the scene are stored in different branches.
Large sections of the scene graph can be discarded merely by ignoring entire
branches in the tree.
After identifying and discarding the objects that do not intersect the view volume,
the remaining objects are trimmed by a process known as clipping, which
essentially slices off the portion of each object that lies outside the view volume.
More precisely, clipping is the process of comparing each individual planar
patch to the boundaries of the view volume and trimming off those portions of
the patch that fall outside.
The results are polygonal meshes (of possibly trimmed planar patches) that lie
entirely within the view volume.
The next step in the rendering pipeline is to identify the points on the remaining
planar patches that are to be associated with pixel positions in the final image.
It is important to realize that only these points will contribute to the final picture.
If a detail on an object falls between the pixel positions, it will not be represented
by a pixel and therefore not be visible in the final image.
This is why pixel counts are heavily advertised in the digital camera market.
The more pixels there are, the more likely that small details will be captured in a
photograph.
The process of associating pixel positions with points in the scene is called scan
conversion (because it involves converting the patches into horizontal rows of
pixels called scan lines) or rasterization (because an array of pixels is known as
a raster).
Scan conversion is accomplished by extending straight lines (projectors) from
the center of projection through each pixel position in the image window and
then identifying the points at which these projectors intersect the planar
patches.
These, then, are the points on the patches at which we must determine an
object’s appearance.
Indeed, these are the points that will be represented by the pixels in the final
image.
In short, if a projector intersects more than one planar patch, it is the point on the
patch nearest the image window that should be rendered.
A popular technique uses an extra storage area, called a z-buffer (also a depth
buffer), which contains an entry for each pixel in the image (or, equivalently,
each pixel entry in the frame buffer).
Each position in the z-buffer is used to store the distance along the appropriate
projector from the camera to the object currently represented by the
corresponding entry in the frame buffer.
Thus, with the aid of a z-buffer, the “foreground/background” problem can be
resolved by computing and storing the appearance of a pixel only if:
1. Data for that pixel has not yet been placed in the frame buffer, or
2. The point on the object currently being considered is closer than that of the
previously rendered object, as determined by the distance information recorded in
the z-buffer.
More precisely, when using a z-buffer, the rendering process can proceed as
follows:
Set all entries in the z-buffer to a value representing the maximum distance from
the camera that an object will be considered for rendering.
Each time a new point on a planar patch is considered for rendering, first compare
its distance from the camera to the value in the z-buffer associated with the current
pixel position.
If that distance is less than the value found in the z-buffer, then:
o Compute the appearance of the point.
o Record the results in the frame buffer.
o Replace the old entry in the z-buffer with the distance to the point just
rendered.
Shading
The final image, the rendering task becomes that of determining the appearance of
the patch at that point.
This process is called shading.
Shading involves computing the characteristics of the light projected toward the
camera from the point in question, which depends on the orientation of the surface
at that point.
The orientation of the surface at the point determines the degree of specular,
diffuse, and ambient light witnessed by the camera.
A straightforward solution to the shading problem, called flat shading, is to use the
orientation of a planar patch as the orientation of each point on the patch.
That is, to assume the surface over each patch is flat.
The result is that the final image will appear faceted (Figure 10.10) rather than
rounded (Figure 10.6).
In a sense, flat shading produces an image of the polygonal mesh itself rather than
the object being modeled by the mesh.
To produce a more realistic image, the rendering process must blend the
appearance of individual planar patches into a smoothly curved appearing surface.
This is accomplished by estimating the true orientation of the original surface at
each individual point being rendered.
Such estimation schemes normally begin with data indicating the surface orientation
at the vertices of the polygonal mesh.
One way is to encode the orientation of the original surface at each vertex and
attach this data to the polygonal mesh as part of the modeling process.
This produces a polygonal mesh with arrows, called normal vectors, attached to
each vertex.
Each normal vector points outward in the direction perpendicular to the original
surface. The result is a polygonal mesh that can be envisioned as shown in
Figure 10.11.
Rendering-Pipeline Hardware
Most computer systems designed for graphics applications, including video game
machines, incorporate these devices in their design.
In the case of general-purpose computer systems, this technology can be added in
the form of a graphics card or graphics adapter, which is attached to the
computer’s bus as a specialized controller.
Such hardware substantially reduces the time required to perform the rendering
process.
Rendering-pipeline hardware also reduces the complexity of graphics application
software.
Essentially, all the software needs to do is provide the graphics hardware with the
scene graph.
The hardware then performs the pipeline steps and places the results in the frame
buffer.
From the software’s perspective, the entire rendering pipeline is reduced to a single
step using the hardware as an abstract tool.
Example: In an interactive video game, the game software transfers the scene
graph to the graphics hardware.
The hardware then renders the scene and places the image in the frame buffer,
from where it is automatically displayed on the monitor screen.
As the game progresses, the software merely updates the scene graph in the
graphics hardware to reflect the changing game situation.
The hardware repeatedly renders the scene, each time placing the updated image
in the frame buffer.
The capabilities and communication properties of different graphics hardware
vary substantially.
If an application (such as a video game) were developed for a specific graphics
platform, it would have to be modified if transferred to another environment.
To reduce this dependence on specific graphics systems, standard software
interfaces have been developed to play an intermediary role between graphics
hardware and application software.
These interfaces consist of software routines that convert standardized commands
into the specific instructions required by a particular graphics hardware system.
Overview
MODULE 5
The Internet has been around since the early [Link] the early years, the Internet only
supported plain text and required precise syntax of computer commands.
Example: mail -s ―mail subject‖ jane@[Link] <<< ―Mail body.‖Most users
found this too challenging, so only computer science researchers at universities used
it.
In 1989, Sir Tim Berners Lee proposed and demonstrated an information management
system based on [Link] 1993, Tim Berners Lee had specified the first version
of HTML.
From Dec 1992–Mar 1993, Marc Andreesen and Eric Bina at UIUC built the Mosaic
web browser.
They added the ―img‖ tag to HTML to handle images and released the web
[Link] became a killer application that popularized the Internet.
Sites like Yahoo offered directories for users to find content on the World Wide
[Link] then, the Internet has become increasingly user friendly as HTML
improved, adding support for images and videos.
The Internet and World Wide Web became a powerful force for information sharing
and [Link] over 5 billion people (over 60% of the world’s population) use
the Internet.
HTML and related technologies made it easy, inexpensive, and meaningful for
anyone anywhere in the world to access the web.
What is HTML?
HTML (Hypertext Markup Language) is the standard markup language used for
creating webpages and web applications.
A markup language is a computer language that is used to apply layout and
formatting conventions to a text document.
The HTML markup language makes text on webpages more interactive and
dynamic.
HTML allows us to specify the placement of images, tables, links, etc. on webpages
using simple text descriptions.
HTML provides the structure and content of a webpage, specifying how text,
images, hyperlinks, tables, and other media should be displayed on a browser.
When you visit a website, say [Link] returned is an HTML page
(Figure 198).
Your browser can understand the page specifications defined in HTML and is able
to render it as a webpage that you can see and interact with.
To see the HTML code that defines the page, you can right click on your webpage (on
most browsers such as Google Chrome or Mozilla’s Firefox) and choose ―View
Page Source.‖ This will bring up text specification of that webpage. (Figure 199)
HTML has been an Internet standard since 1993, and all common browsers (e.g.,
Google Chrome, Apple Safari, Microsoft Internet Explorer, and Mozilla’s Firefox)
understand HTML.
So, when you visit any page written in HTML, say [Link] on any
browser, they all receive the same text, and the page looks the same on all these
browsers.
For example, the Google home page looks the same on all browsers.165
HTML is a crucial part of the web and forms the foundation of all webpages.
HTML uses tags to define elements.
Tags can have attributes to further describe elements.
These tags and attributes are used to create the visual and semantic structure of a
webpage.
Though HTML is primarily designed for machines to interpret, as you will see in this
chapter, its simplicity makes it easy even for humans to understand the content.
Virtually all information and tools are presented to end users as webpages.
You access your school resources on the web, check email on the web, track bank
accounts on the web, your teachers enter your grades on the web, and so on.
All these webpages are created using HTML.
Therefore, HTML is a foundational technology that all modern professionals will find
useful.
HTML is a simple [Link] essentially encloses text within tags to tell the browser
how to render the enclosed text.
For example, the browser will render <b>this is bold text</b> as this is bold text.
<i>this is italicized text</i> will be rendered as this is italicized text.
You don’t need fancy editors to create an HTML [Link] could create an HTML
page by typing HTML commands on a notepad and saving the file as .html (a file
with an html extension).
All HTML pages follow the same basic [Link] contain a DOCTYPE
declaration at the top, followed by an HTML [Link] HTML section comprises of
a HEAD and BODY.
Figure 200 shows a basic example.
DOCTYPE Declaration: This is the first line of an HTML page, and it tells the
browser what kind of document to expect, particularly, which version of HTML.
HTML tag: All code in HTML is declared using tags.A tag is a special keyword that
is enclosed by <>.The HTML tag defines the start and end of an HTML
[Link] in the HTML document is nested within the opening and
closing HTML tags, i.e., between <html> and </html>.Tags are closed with the ―/‖
symbol in the tag, Thus, </html> indicates the end of the section that began with the
<html> tag.
Head tag: The head tag contains information about the HTML document that is
mostly not displayed to the [Link] section includes the title of the page, any
information about the page such as author information and version history (this is
often called meta information), information about the look and feel (called
stylesheets), and information about user interactions (specified using a language
called JavaScript).You can also include additional description and relevant keywords
about your webpage within the head tag, so search engines can more easily identify
your [Link] only content within the head that is displayed to the user is information
within the title tag, which is displayed as the title of your browser tab.
Elements in HTML
Like most electronic documents, webpages have text, images, tables, and links to
other pages.
The text may be bold, italicized, and use different font sizes.
You might see ideas listed as bullet points or numbered lists.
You may also see forms, with different input elements for you to fill in.
You can represent each of these elements with HTML tags and build a complex
HTML page that asks users to enter data and then sends the inputted data to a server
for further action.
The text within the <p> tag is displayed as a separate paragraph, with a line break
before and after it (Figure 201).
The text within the paragraph tag can include any type of content, such as text,
images, links, or other HTML elements.
When creating a paragraph, you could use attributes to further specify the kind
of paragraph you want.
To create a paragraph with text in red color, try this:
<p style=―color:red;‖> This is a red paragraph.</p>
Heading Tag: Headings are the essential mechanism to create structure within pages.
HTML supports headings with six levels of headings, ranging from <h1> to <h6>.167
The <h1> tag represents the main heading on a page and is typically used for the page
title, while the other headings <h2> to <h6> are used for subheadings.
It is best practice to not skip heading levels, i.e., subsections of <h1> should use
<h2>, not <h3> or <h4> etc.
Figure 202 shows an example.
The subscript <sub> and superscript <sup> tags are used to display text as subscript
or superscript (Figure 204).
These tags can be helpful to display scientific formulas.
Adding Links
Adding Images
You can add images to your HTML page with an <img> tag.
Like the <a> tag, the <img> tag also has a required attribute, that specified the image
file to be displayed.
You need to have the source (src) attribute to give the location of the image, so the
browser can get the image and display it on the webpage.
Optionally, you can also have other attributes like width and height parameters to tell
the browser how large the image should be on the page (Figure 206).
Images draw the attention of visitors.
So, not surprisingly, company logos, background images, and advertisements are
carefully and tastefully designed to draw the attention of visitors and convey the right
message about the site to them.
Creating Lists
To create lists in HTML, such as a list of things to buy, places to visit, or people to
invite, HTML offers two options—bulleted lists and numbered lists.
You have the <ul> tag for unordered (bulleted) lists and the <ol> tag for ordered
(numbered) lists.
You can indicate the list items with the <li> tag and nest lists within lists (Figure
207).
Creating Tables
To display structured data, such as price lists, club memberships, class enrollments
etc., HTML supports [Link] are created using the <table> tag.
Tables have some additional necessary elements to specify rows and cells.
The <tr> and <td> tags define the rows and cells of the table, respectively.
You can also use the <th> tag to define table headers, which are typically bolded and
centered.A <table> will have one or many <tr> tags, indicating the rows in the table.
Each <tr> in turn encloses many <td> tags, indicating the cells within the row.
The <td> tag represents a cell and encloses the contents of the cell (Figure 208).
Creating Forms
They are an essential part of web development and enable webpages to collect data,
provide a personalized user experience, and perform various actions based on user
input.
Forms are created using the <form> tag.
Every form also has multiple <input> tags to specify the kind of input you want from
the user.
These <input> elements can be text, number, file, or image.
Each of these can be specified by choosing the right value for the ―type‖ attribute of
the <input> tag.
The data collected in a form is sent to the server for processing using the action
attribute of the form tag.
In the example in Figure 210, we have a simple form to collect the first name and last
name of the user.
When the ―Submit‖ button is pressed after entering the first and last names, the form
data will be sent to the processor located at server_submit.php.
The processor will respond after processing the name, for example by saving it in the
database, and customizing the response with the name, etc.
To create a multi-line input element, use the tag ―textarea.‖ You can also specify
how wide and tall this text box should be using ―rows‖ and ―cols‖ attributes. To
create a dropdown that allows users to select from a list of things, you can use the
select tag (Figure 211).
There are additional form input types to handle common input scenarios.
A radio button is a great choice if you want to give users multiple choices, but you
want them to pick only one option.
The concept of a radio button dates to radios that had mechanical buttons to select a
station.
You could only select one button at a [Link] you pressed another button, then the
previously pressed button would pop out automatically.
This concept has carried over to HTML forms and such selectors are called radio
buttons, tracing their lineage.
So, even though you may see many options, selecting a new option will deselect your
previous [Link] 212 shows an example.
The ―Checkbox‖ element in HTML derives its name from paper forms with
checkboxes. You can select one or many checkboxes. Similarly, creating a
―Checkbox‖ element in HTML will allow your users to select one or more choices
(Figure 213).
If you want users to enter a date, you may want to use the ―Date‖ element. Your
browser will recognize this element and display a calendar (Figure 214). Once a date
is selected, the browser updates the field with the selected date.
W3Schools is a great resource to learn about styles.171 You can tweak more aspects
about the look and feel of your webpage than you can imagine.
Once you develop some comfort with CSS, the next step to improve your productivity
as a web developer is to create a separate CSS file (Figure 216) and then link it to
your HTML file as shown in line 4 of Figure 217.
expect from the school or school district. When you visit a website (say,
[Link]), there are servers (owned and managed by a service provider)
waiting for you to reach out to them.
To support all their users and their requests, websites have a collection of webpages
that are connected to one another through weblinks. This way, when you go from one
Google webpage to another, you have a seamless experience.
For example, when you search for a book on Google, you see a collection
of results. If you click on a Google sponsored ad after reviewing the
results, another result page opens. The entire flow is managed by multiple
Google webpages and application programs that handle these user
requests.
To accomplish this, websites should be coherent, easy to navigate, and
accomplish what you set out to do. The same need for coherence and ease
of use applies to much larger sites where you write your blog, sell your
products, or promote your company.
Building a website is a resource-intensive exercise. You must plan, build,
and deploy your website. Just like you wouldn’t start constructing a house
without having a plan, you don’t want to build a website on the fly.
Therefore, once you learn the elements of webpages including HTML
and CSS and are ready to build a website, it is a good idea to start with
storyboards.
Storyboards are visual representations of creative projects.
When used with websites, storyboards help all members of the development team
identify all the users of a website and their expected interactions.
Once storyboards are developed, they are usually communicated using wireframes.
Wireframes are illustrations of the webpage that focus on space allocation for the
elements of the page and their intended behaviors.
Wireframes are intended to be simple and disposable and typically do not include any
styling, color, or graphics.
Storyboards and wireframes are both important tools in the design and development
process of a website, but they serve different purposes and are used in different
contexts. Storyboards are about the storytelling and visual components and
wireframes focus on the user interface and interaction aspects of a website.
For large scale projects, you should first do storyboarding before moving on to
wireframing tools. While storyboarding evolved from film and drama, the concept has
found a home in website development.
It is useful to understand the high-level overview and flow of the webpages and
visualize the user experience. Once you and your team agree about the flow, you can
then move to wireframing the design.
A wireframe outlines the structure and content of a website without including design
elements such as colors, typography, or images. Wireframes are created during the
planning phase to help designers and developers identify and address potential design
and usability issues.
Wireframes typically include boxes and lines to represent the placement of different
elements on the page, such as headers, navigation menus, content sections, and calls
to action. Balsamiq175 is a popular wireframing software that lets you quickly
wireframe your webpages and then share it with your team and customers to get their
feedback before investing development effort to create the website (Figure 218).
Wireframing tools such as Balsamiq offer templates to pick, drag, and drop different
webpage elements and put them on the screen to quickly develop wireframes. You
can use wireframes to design browser-based webpages or for mobile apps like IOS or
Android.
Building wireframes to refine application concepts is an excellent, low-effort, no-cost
way to test new application ideas.
Structure of a Website
If you want to create a website, your website admin (or you) will need to have a
webserver (e.g., Apache webserver) to host the website.
You will need to save your HTML pages and other supporting files in an organized
folder structure on the webserver. We will now discuss the basic structure of a
website so you can understand how all the elements of a site are integrated together.
It is a good idea to include the folder structure of your website in your wireframe, so
it is easy to see how it is organized on your webserver.
Figure 219 shows an example of the folder hierarchy of a website and how it ties to
the different sections of the site together.
It is useful to maintain a consistent organization for the files within each folder.
Figure 220 shows a popular organization structure for the files in a folder. The
starting point of your application or website is typically called the ―Root‖ folder of
your site. A file called ―[Link]‖ is displayed by default if someone visits your
website and does not specify a specific file name.
Organizing folders for Images, Fonts, Common libraries, JavaScript, and Stylesheets
(Figure 220) makes it easier to manage and maintain files.
Search engines and users will also be able to navigate the website easily.
Additionally, many websites also use a Content Management System (CMS) that
provides a graphical interface to organize and manage the files and contents of
websites.
You can have all your HTML pages in a separate folder, or you can choose to divide
your website into different functional areas and have a separate webpage for each
topic within it.
In Figure 221, you can see how the submenus of a website correspond to similarly
named folders on the server. For example, if a user visits your home page, the server
will show the root-level [Link] file. However, if the user clicks Submenu 1, then
the [Link] within the Submenu 1 folder will be displayed.
Hosting a Website
Hosting a website means making it accessible to the public over the Internet by
storing the website’s files and data on a webserver.
A webserver is a computer that is connected to the Internet and is designed to store
and deliver webpages to users who request them through their browsers.
When you host a website, you essentially rent space on a webserver from a hosting
company or provider.
This allows your website to be stored on the webserver and made available for access
over the Internet.
The web hosting company also provides a range of services, such as server
maintenance, security, and technical support, to ensure that your website is always
accessible and runs smoothly. You’ll need to upload your files to the webserver and
configure your website settings so users can find your site on the web.
Once your website is hosted, users can access it by typing your domain name (e.g.,
[Link]. org) into their web browsers. This sends a request to the webserver
hosting your website.
The webserver then responds by sending the requested webpages back to the user’s
web browser, which displays them on their screen.
There are many popular web hosting sites available, each with its own features,
pricing, and capabilities. Some of the most popular web hosting sites are
GoDaddy,Bluehost, SiteGround, HostGator,DreamHost, A2 Hosting, InMotion
Hosting, and Wix.
It’s important to research and compare different options to find the one that best
meets your needs and budget.
Website Editors
There are multiple ways to build HTML pages. One way is to code it from scratch
using the HTML elements like <table>, <text>, <img>, and others.
Another way is to use a wireframe tool like Figma and then use the tool’s conversion
feature to convert the wireframe into HTML code.
Another popular way is to use a WYSIWYG (Pronounced WIZ-EEE-WIG) editor.
WYSIWYG is a popular industry acronym for ―What You See Is What You Get.‖
In the context of HTML editors, a WYSIWYG editor is a software program that
allows users to create and edit HTML documents without having to know the HTML
code.
With a WYSIWYG editor, users drag and drop website elements such as images and
tables on a drawing canvas, and see the webpage they are creating as it will appear in
a browser without having to manually code the HTML.
WYSIWYG HTML editors make web technologies accessible to everyone.
They are popular among non-technical users, such as bloggers, content creators, and
small business owners, who may not have the technical expertise to create webpages
using HTML code.
Some popular free WYSIWYG HTML editors include Brackets from Adobe, Phoenix
code editor from the Brackets developer community, and SeaMonkey from the
Mozilla community.
There are also commercial WYSIWYG editors, including Adobe’s Dreamweaver.
Website hosting providers like [Link] can also give you access to website builders
and editors.
The website builder is typically a WYSIWYG platform, where you can drag and drop
elements on to the page. When you are ready, you can click the ―Publish‖ button to
deploy your website without writing or editing a line of code.
Google Sites ([Link]) is another website hosting provider that has its
own WYSIWYG webpage builder (Figure 222).
The capabilities of HTML editors are evolving rapidly. While the editors share most
of the same basic capabilities, they can also offer additional capabilities depending
upon the needs of their target audience, pricing structure, etc.
For example, commercial editors may offer advanced features like a library to
maintain your common themes, icons, a collaboration framework (so you can get your
work approved before it gets published), and a built-in version control system (so you
can go back to any previous version). Check out the capabilities and pricing models of
the different editors to find one that best fits your needs.
HTML Extensions
The popularity of the web has led to several innovations in web design, collectively called
DHTML. The concept of tags has also been extended to XML, which generalizes publishing
and even allows machines to directly exchange information with each other.
Developers use multiple web technologies to enable this interactivity. The collection
of web technologies including HTML, CSS, and JavaScript to create interactive
websites is called Dynamic HTML, or DHTML.
One way to look at the DHTML technologies is to think of HTML code as answering
the question ―What to display,‖ CSS code as answering the question ―How the
display should look,‖ and JavaScript code answering the question ―How the webpage
should interact with the user.‖
Using DHTML, you can create webpages that respond to user actions such as mouse
clicks and hover events, without requiring the page to reload or requiring server-side
processing.
Another recent development, popularized by social media websites such as Facebook
and Twitter, is called the Single Page Architecture (SPA). Single Page Architecture
(SPA) is a development approach in which the content and functionality of a web
application is contained within a single HTML page. I
nstead of navigating to separate pages when clicking on links, the user remains on the
same page while sections of the page get dynamically updated based on the user’s
interaction with the website. The initial HTML page is loaded from the server, and
then subsequent interactions with the application are handled through JavaScript.
The JavaScript code updates sections of the page based on user interactions without
requiring a full page reload, offering a seamless experience to visitors.
SPAs offer several advantages to page visitors, including a smoother user experience,
faster page load times, and easier development and maintenance due to the separation
of client-side and server-side code.
Popular examples of SPAs include Gmail, Facebook, and Twitter. Their convenience
is also a source of criticism of single page applications—users keep scrolling SPAs,
anticipating interesting news, a phenomenon popularly labeled doom-scrolling.
XML is very useful if the organization you work for does data exchange, for example
with buyers, sellers, credit card companies, banks, and other organizations. Data
exchange between companies and customers is a critical aspect of online commerce,
which makes XML a key language you should know about.
A unique feature of XML is that it allows users to create their own custom tags to
represent specific data structures and identify elements within a document.
This flexibility makes it suitable for a wide range of applications, including web
services, data storage and retrieval, and configuration files for computer applications.
XML standards, which specify tags for specific uses, have been developed for most
of the important information exchange contexts.
For example, the XML Business Reporting Language (XBRL) helps organizations
report financial performance in a universal format.
Since 2018, the U.S. Securities and Exchange Commission, the principal regulator of
publicly traded companies in the United States, has required that companies submit
their annual reports using XBRL.
An example is shown in Figure 224.
A critical feature you can see in the example is that the numbers are clearly associated
with their corresponding meanings specified by the International Financial Reporting
Standards (IFRS).
For example, the underlying XML conveys to every financial publishing technology
anywhere in the world that the highlighted number of $3,404,031 represents salary
expenses for the organization.
This makes it easy and precise for investors to compare the performance of different
organizations, and for regulators to ensure that the numbers are correctly reported.
Finally, XML viewers can format documents for easy human readability, as you see
in Figure 224.
One of the key features of XML for recordkeeping, electronic commerce, healthcare, and
other industrial applications is that computers can validate data against a defined schema or
document type definition (DTD).
Computers can review every element of a document and ensure that the data is properly
formatted and satisfies all necessary properties. For example, a DTD can specify that profits
or losses must be numbers, or, as in the example of Figure 225, a person must have a name.
This helps avoid errors and inconsistencies in electronic documents. Figure 225 introduces the
structure of XML documents. In this example, the XML document starts with a declaration
that specifies the version of XML being used (―1.0‖) and the character encoding used to
encode the document (―UTF-8‖).
The main content of the document is contained within the <person> element, which has
several child elements representing different aspects of the person’s information.
The <name> element contains the person’s name, the <age> element contains the age,
and the <address> element contains the street, city, state, and ZIP code.
The DTD can specify the properties of each of these tags, including whether they are
required or optional.
Note that each element has a corresponding closing tag (e.g., </name>) marking the
end of the element’s content, just like HTML.
Also note that elements can be nested inside other elements to create a hierarchical
structure, as with the <address> element in this example.
There are several reasons why the essential concept of XML is widely used:
1. XML can be easily read by humans and parsed and processed by computers.
2. XML is not tied to any specific platform or programming language, which
makes it very flexible for data exchanges on the Internet.
3. XML is designed to be extensible. Users can define their own tags to describe
data in a way that is specific to their needs. This allows for the creation of
custom data structures that can be tailored to particular use cases.
4. XML documents can be validated against a defined schema or document type
definition (DTD). You can easily ensure that data is properly formatted and
structured to avoid errors and inconsistencies.
5. XML is used for data exchanges between systems and applications. This is
due in part to its flexibility, extensibility, and its ability to represent a wide
range of data types and structures.
6. XML is used for representing data, not formatting or styling. This allows for a
clear separation between content and presentation, making it easier to reuse
data in different contexts or formats.