Update the form look and feel using Cascading Style Sheets.
CSS 3.0 is a declarative language that defines rules about how elements of a document (and the document itself) appear:
The more you know about CSS, the more effective the form style will be.
CSS is great for managing web page accessibility concerns including:
Advice: Be conservative with gradients.
This training module is not comprehensive:
If you have none or very little CSS experience:
If you are an experienced programmer:
The idea is to introduce the capabilities so you can pick it up and run with it.
There are 3 ways to employ CSS on a web document:
<style> element within the web document.There is a fourth: Some compbination of 1, 2, and/or 3.
Benefits and Drawbacks of file-based, style element rules, and in-line styles:
<style> tag mixes HTML and CSS together into the same file, making it more difficult to maintain by adding lots of clutter. However, it is easier to deliver a single-file solution (HTML + CSS + Javascript in one file) than to deal with accurate distribution to users.Recall: HTML provides the Layout for the content of a web page.
CSS defines properties like color and width so the page and HTML elements know what size and color they are.
Inheritance:
Special CSS functions allow selecting what elements in a hierarchy have styles applied to them.
As an example, a font family and background color are defined and applied to the body element:
body {
font-family: 'Segoe UI', Tahoma, Verdana, sans-serif;
background: #3399FF;
}
HTML elements within the <body> element will inherit CSS properties that apply to them:
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<h2>Document Heading</h2>
</body>
</html>
This is the “cascading” part of CSS. Take advantage of it when setting styles to your web page.
Browser Developer Tools:
Inspector or Elements Tab: Interact with HTML, CSS, and “events” that make up the structure, style, and behavior (respectively) of the web page.When a style doesn’t seem to be applied, or doesn’t do what you thought it should, start by looking at the Elements tab, click on the element with the problem, and review the Styles sub-tab (next to Computed and Layout).
InspectHTML is displayed on the left (the document Layout), and CSS is displayed on the right (the style application tree).
Styles tab (on the right) shows the CSS rules that are applied to that element.Note the following style application notations:
element.style: Style properties applied directly to the selected element.A note about user agent styling:
user agent styles are overridden by the CSS that you write.Just like Javascript, CSS can target HTML elements individually, as a group, or through inheritance (the “cascading” part of CSS).
Target elements of type:
section {
display: flex;
justify-content: flex-end;
padding: .2em;
}
<section>
<input type="button" name="SaveButton" id="saveButton" value="Save Data" />
</section>
Target elements with some class:
.input-container {
width: 100%;
margin: auto;
text-align: center;
padding: .2em;
}
<div class="input-container">
<label for="mycall">Enter your callsign:</label>
<input type="text" name="mycall" id="myCallsign" />
</div>
Target one specific element by unique ID:
#submit-container {
display: flex;
justify-content: flex-end;
padding: .2em;
}
<div id="submit-container">
<input type="submit" name="Submit" value="Submit" />
</div>
font-family: Pick easy to read, well-spaced fonts like Segoe UI, Tahoma, Verdana, and non-serif fonts.
font-size: 16px is a common default, and 18px is a pretty good setting to help improve readability. The downside is if you assign a default font-size, adjusting font-size of other elements requires a little more work. In any case, larger or smaller screens should probably use slightly larger or smaller values - see Responsive Design section below for more information.
background: Assign a color to the background of the element(s). Best supported color definitions are in hexadecimal (0-F) formatted and assigned like #rrggbb (see next subsection).
width and height: Assign element size using pixels (px), percentage %, and other units (there are many to choose from).
margin, border, and padding:
display Defines how the element will be displayed:
#000000#FFFFFF#FF0000#00FF00#0000FF#FF00FF#AAAA00#00FFFF#1199FF#FF9911As you change Hex Color values, the Code Editor might pop-up a color-picker for you to preview your selection, and to allow you to point-and-click at the actual color and shading you want.
Also note: Transparecy is possible by adding a fourth HEX value. For example, a semi-transparent blue would be #0000FF88
Make web pages render well on varying screen sizes and resolutions, maintaining usability and readability.
This is a very large, advanced topic. There are benefits from knowing a few basics, followed by some studying to learn the advanced techniques to make an awesome web page.
CSS will apply rules based on what the browser document says the resolution and screen dimensions are:
body {
font-size: 18px;
}
@media screen and (width < 650px) {
label,
input,
button {
font-size: 0.7em;
}
form {
max-width: 100%;
padding: 0.4em;
background: linear-gradient(#11ccee, #11aaff);
border-radius: 20px;
}
}
@media screen and (width >= 650px) {
label,
input,
button {
font-size: 1em;
}
form {
max-width: 650px;
padding: 0.6em;
background: linear-gradient(#11ccee, #11aaff);
border-radius: 20px;
}
}
The @media statement tells CSS to only apply the rules when the parameters are met:
screen: The Screen object is available. This could also be an evaluation like screen.pixelDepth < 8, meaning fewer colors are available so use a grayscale instead of full color spectrum.width: The width of Screen in pixels. The condition could be height instead or a combination of the two.Keep the number of @media conditions to a minimum to keep the benefit of the effort very high.
Developer Tools has a little button named ‘Toggle Device Toolbar’ (or similar - in Chrome it is in the upper-left hand corner, just to the left of the ‘Elements’ tab).
Clicking this button alters the ‘screen’ property of the browser display window. Doing so now will probably load an iPhone view with dimensions that represent a mobile device.
There is a “Dimensions” drop-down in the upper-left area of the browser window that allows selection of many common mobile device screen sizes.
There is a “Rotate” button in the upper-right area of the browser window that allows rotating the screen.
Advice:
styled-form.html from module 2 and name it responsive-form.html (or something that makes sense to you).<style> element within the <body> of the html and save the changes.responsive-form.html by replacing “Form Fields Start” example code with “Form Fields Responsive” example code, save the changes, and refresh the browser window.Form Fields Start (just the HTML):
<label for="mycall">Enter your callsign:</label>
<input type="text" name="mycall" />
<label for="tocall">Enter recipients callsign:</label>
<input type="text" name="tocall" />
Form Fields Responsive:
<div class="horizontally-aligned">
<label for="mycall">Enter your callsign:</label>
<input type="text" name="mycall" />
</div>
<div class="horizontally-aligned">
<label for="tocall">Enter recipients callsign:</label>
<input type="text" name="tocall" />
</div>
Adding CSS rules to apply to .horizontally-aligned will provide even more control over the placement of the elements.
Adjusting Media Queries will help to refine exact bahavior based on screen sizes your users are most likely to be using. Remember to keep the number of cutoff values to just a few to keep for over complicating the code.
Put files into Winlink Express Global Folders\Templates directory:
4-form-style\tagged-styledform-template.txt4-form-style\styled-form.htmlRemember: You can move the javascript to a separate file if you wish, but remember to:
<script ref=""> element just before the end of body </body> element tag.tagged-styledform-template.txt in the Global Templates directory.styled-form.html form.Move on to Module 5 - Create a Form Viewer
Return to Root README