Test your skills: Advanced styling
The aim of this skill test is to assess whether you've understood our Advanced form styling and UI pseudo-classes articles.
Note: You can try solutions in the interactive editors on this page or in an online editor such as CodePen, JSFiddle, or Glitch.
If you get stuck, you can reach out to us in one of our communication channels.
Advanced form styling 1
In our first advanced styling tasks, we want you to handle making a search input as consistent as possible across browsers — a trickier task than with standard text inputs, even on modern browsers.
We've already provided you with a basic reset to build upon.
- First of all, try giving the search box a consistent width, height, padding, and border color across browsers.
- You'll find that some browsers will not behave in terms of the form element's height. This is due to native OS styling being used in some cases. How can you remove this native styling?
- Once you've removed the native styling, you'll need to add back one of the features it was providing, to keep the same look and feel we originally had. How do you do this?
- One thing that is inconsistent across browsers (particularly looking at Safari here) is the position of the standard blue focus outline. How can you remove this?
- There is a major problem with just getting rid of the blue focus outline. What is it? Can you add some kind of styling back in so that users can tell when the search box is being hovered or focused?
- Another thing that commonly denotes a search box is a magnifying glass icon. We've made one available in the same directory as our HTML files — see search-24px.png — plus a
<div>
element after the search input to help you attach it, should you need it. Can you figure out a sensible way to attach it, and can you use some CSS to get it to sit to the right of the search box, and be lined up vertically as well?
Try updating the live code below to recreate the finished example:
Download the starting point for this task to work in your own editor or in an online editor.
Advanced form styling 2
In our next task we provide you with a set of three radio buttons. We want you to give them custom styling.
We've already provided you with a basic reset to build upon.
- First of all, get rid of their default styling.
- Next, give the radio buttons a reasonable base style — the style they have when the page first loads. This can be anything you like, but you probably want to set a width and height (of somewhere between about 18 and 24 pixels), and a subtle border and/or background color.
- Now give the radio buttons a different style for when they are selected.
- Align the radio buttons nicely with the labels.
Try updating the live code below to recreate the finished example:
Download the starting point for this task to work in your own editor or in an online editor.
Advanced form styling 3
In our final task for this assessment series, we provide you with a feedback form that is already nicely-styled — you've already seen something similar if you've worked through our UI pseudo-classes article, and now we want you to come up with your own solution.
What we'd like you to do is make use of some advanced pseudo-classes to provide some useful indicators of validity.
- First of all, we want you to provide some specific styling to visually indicate which inputs have to be filled in — they cannot be left empty.
- Second, we want you to provide a useful visual indicator of whether the data entered inside each input is valid or not.
Download the starting point for this task to work in your own editor or in an online editor.