How-to articles, tricks, and solutions about HTML

How to Right Align a Button with CSS

In this tutorial, we'll demonstrate how to align a button to the right with CSS. For that purpose, you need to use the CSS float property with its “right” value.

How to Create a List With Dashes in HTML

In this tutorial, find out how it is possible to style a list with dashes instead of bullet points. Use the :before pseudo-element with the content property.

How to Make the Middle Item Stay Centered

Read this tutorial to find out how you can make the middle element stay centered regardless of the widths of the siblings. This can be done by using Flexbox.

How to Create a Table with a Fixed Header and Scrollable Body

In this tutorial, find some methods of creating an HTML table with a fixed header and scrollable body. Here, we suggest using some methods. See examples.

How to Create a Two-Column Div Layout with the Right Column Having Fixed Width

In this tutorial, we’ll explain how to create a two-column <div> layout with the right column having a fixed width. Here, you can find some examples.

How to Disable Form Fields with CSS

In this tutorial, we’ll demonstrate how it is possible to disable form fields with some CSS. For that, you can use the pointer-events property set to “none”.

How to Set Default HTML Form Focus Without Javascript

In this tutorial, you’ll see how to set the default HTML form focus. This can be done without Javascript. For that, use the HTML “autofocus” attribute.

How to Use the HTML <fieldset> Tag

In this tutorial, you will find some examples of using the HTML <fieldset> element. Besides, you can find out why in general we need the <fieldset> element.

How to Make the Text Bold in HTML

In this snippet, you’ll see how to make the text bold by using the <strong> or <b> tags. Also, you can use the CSS font-weight property in the HTML part.

How to Set an Equivalent of the "cover" Value of the background-size Property for an <img> Tag

In this snippet, we’ll show how you can set an equivalent of the “cover” value of the background-size property for the <img> tag. Use the object-fit property.

How to Allow Only Positive Numbers in the Input Number Type

In this snippet, we’ll demonstrate how to allow only positive numbers in the input number type. You can use the “min” attribute to specify restrictions.

How to Handle Page Breaks when Printing a Large HTML Table

In this snippet, we’re going to show how to deal with the problem connected with page break when you print a large HTML table. Use some CSS properties.

How to Display an Ordered List with Nested Counters

In this snippet, we’re going to show how you can display an ordered list with nested counters by using CSS. See some methods of overcoming this problem.

How to Make HTML <dt> and <dd> Elements Stay on the Same Line

In this snippet, we’re going to demonstrate some ways of forcing the HTML <dt> and <dd> elements stay on the same line. You can use the CSS float property.

How to Display Symbols with HTML

In this snippet, you can see how to add and display different symbols, such as infinity ampersand and other symbols. For that, you need to use HTML Entities.

How to Remove Focus Around Buttons on Click

In this snippet, you can see how to remove the focus around a button on click. To solve this problem, you use the CSS outline property with the “none” value.

How to Control the Space Between Bullets and <li> Elements

In this snippet, you can find out how to control the space between bullets and <li> elements. You can use the HTML <span> element and the CSS left property.

How to Use the "required" Attribute on the <select> Element in HTML5

The “required” attribute works only on empty values. In this snippet, we’ll show how to apply it to the HTML <select> element. Read and find some examples.

How to Force the Content of the <div> Element to Stay on the Same Line

In this snippet, we’ll demonstrate how to force the content of the HTML <div> element to stay on the same line. Use the overflow and white-space properties.

How to Remove Default Arrow Icon from a Dropdown List

In this snippet, we’re going to demonstrate how you can remove the default arrow icon from a dropdown list. For that, you can use the appearance property.

How to Style Even and Odd List Items

In this snippet, we’re going to demonstrate how to style the even, odd, or both the even and odd items of an unordered list. See examples with each of them.

How to Add an Onclick Effect with HTML and CSS

In this snippet, we’ll demonstrate how to add an onclick event in CSS. The best way of creating an onclick effect is using the well-known checkbox hack.

How to Open a Link From <iframe> in the Parent Window

In this snippet, you can find out how it is possible to open a link from the HTML <iframe> element in the parent window. For that, you can use the <base> element.

How to Make the Text Input Non-Editable

In this snippet, you can find two methods of making a text input non-editable. Use either the HTML “readonly” attribute or add the CSS pointer-events property.

How to Add a Vertical Line in HTML

In this snippet, we’ll show how to add a vertical line on the left and right sides, as well as how to center it and how to add a vertical line before a text.