Windows.  Viruses.  Notebooks.  Internet.  office.  Utilities.  Drivers

From the author: I greet you. The need to present several blocks on a web page in one line is a very common task faced by layout designers. It occurs when laying out almost every template, so we all need to know and apply the basic ways to change the behavior of blocks anyway.

Before we look at the most common tricks, I would like to recall a little theory. Web page elements are divided into block and inline elements. And the difference between them is very simple - lowercase ones can be located on one line, but block ones cannot. Of course, the differences do not end there, but this is the main difference. Blocks can already have indents at the top and bottom (inline ones don’t), and more properties can be applied to them.

Basic ways to line up blocks in css

We will not complicate anything, there are 3 main ways:

Convert blocks to inline elements. In this case, block properties are lost, so this option is almost never used.

Make the desired elements block-inline. This is a special type in which the element retains its properties, but at the same time allows other blocks to be located nearby.

Make elements float using the float property.

Let's take a look at these options. Flexbox, tabular display and other points will not be considered. So let's say we have 3 subheadings.

Heading 1

Heading 2

Heading 3

Naturally, all css properties must be written in separate file(style.css) that needs to be included in the html document. In this file, I will write a minimal style so that our subheadings can simply be seen.

h3( background: #EEDDCD; )

h3 (

background : #EEDDCD;

Here they are on the page:

There they behave like blocks. Each is located on its own line, there are indents between them. If you wish, you can also set any internal indents and generally do anything.

Let's convert to strings and immediately add indents. To do this, the h3 selector needs to add the following properties:

display: inline; padding: 30px

There are 2 main problems that arise when using this technique. The first is the minimum offset. It is formed due to the fact that in the code between the blocks there is one space, which forms this indent. If this issue needs to be addressed, there are 2 main options:

In html, place the code of the necessary blocks in one line without spaces

Put down a negative margin on the right -4 pixels. That's how long one space takes.

The second problem is that with different heights of elements, display problems can occur. All in all, the best option- floating blocks. Instead of display: inline-block we write this:

Blocks in a line using the framework

I must say right away that if you are going to use any normal css framework (for example, Bootstrap), then it is still much easier there. All css-code responsible for the arrangement of elements has already been written and you will only have to set the correct classes. To do this, it is enough to learn the grid system, and you will be able to make multi-column responsive templates without much difficulty. At least it will be much easier than writing css from scratch.

Another problem of writing code from scratch arises just when you need a responsive design. Of course, you can implement it yourself by owning media queries, but it will be much more difficult if you have a complex template.

For example, when you have big screens there should be 4 columns, on the middle ones - 3, and on mobile phones- 2. With the help of frameworks such as Bootstrap, or rather with the help of its grid, to implement this is literally a matter of a few minutes.

Smoothly transferring the topic to the Bootstrap framework, I will once again note that if you are faced with the task of laying out a complex adaptive template, then it is simply a sin not to use the grid. It doesn't even need to be connected. full version framework - you can customize it and stop there only what you really need.

You can learn how to work with the framework using . The theory is explained there, but the most important thing is the practice. You make up 3 adaptive templates and get great experience, which will allow you to make up websites to order or for yourself. And if you want to get acquainted with the benefits and features of the framework for free, I suggest you check out our series of articles on Bootstrap, as well as on laying out a simple layout. I wish you success in layout and site building in general.

Greetings to all readers. Periodically, the masters face the problem of how to make a horizontal or vertical line with using HTML or with using CSS. That's what I'm going to tell you about today.

Lines in CSS

There are several ways to make lines. One such way is to use CSS. More precisely, with the help of Border. Let's look at an example.

And here is the result.

Horizontal and vertical line with css.

Lines in CSS can be drawn using the Border operator. If you just want a rectangle with a fixed border width, then you can simply use this operator and give it a value. For example border:5px solid #000000; will mean that the box borders are 5 pixels wide in black.

However, if you need to set not all the boundaries, but only some, then you need to specify exactly which boundaries are needed, and what value each of them will have. These are the operators:

  • border-top - sets the value of the top border
  • border-bottom - sets the value of the bottom border
  • border-left - sets the value of the left border
  • border-right - sets the value of the right border.

Vertical and horizontal line in HTML

You can also create lines in the HTML itself. To do this, you can use the hr tag.

In this case, a horizontal line will be drawn, one pixel high and full width.

But this tag, you can set some values.

  • Width– sets the line width value.
  • color- sets the color of the line.
  • Align- sets left, center, right alignment
  • size– sets the value of the line thickness in pixels.

Using the hr tag, you can also set a vertical line. But in this case, you will have to resort to styles again.

In this case, a vertical line will be drawn one hundred pixels high, one pixel thick, and five pixels indented.

Conclusion.

Well, now you know how you can set a vertical and horizontal line. Lines can be set as on regular sites, with using HTML, and set on a site that uses a CMS, for example, WordPress, but in this case, you will need to switch to HTML mode.

Well, if you have any more questions, ask them in the comments.

It would seem, why might four methods be needed? After all, almost every person uses one method to which he is accustomed. For example, I pressed Shift and the dash key several times, and that's how a horizontal line turned out.

But what if this results in a dotted line, but you need a solid one?
- Most likely, the Shift key on the keyboard is faulty. Here are some other ways to help.

3.
4.
5.

Perhaps the most familiar way to make a line in Word is to use a couple of keys on the keyboard.

I Thin, thick, double, dotted line using the keyboard

Below is a drawing of a keyboard with an English layout, but without a Russian layout, but this does not matter, because we are only interested in three keys: Shift, dash and Enter.

Rice. 1. Three keys on the keyboard: Shift, dash and Enter for a continuous horizontal line in Word

With these three keys, you can draw a continuous horizontal line in Word: dashed or solid, thin or thick, long or short.

1) By pressing the “-” (dash) key several times in Word editor we get a dotted line of any length.

To do thin long line for the entire width of the page:

  • We find the “dash” key on the keyboard (to the right of the “zero” key, in the green frame in Fig. 1).
  • From a new (!) Line in Word, press this key several times: -
  • And then press the "Enter" () key. Several printed dashes will suddenly turn into a continuous horizontal thin line across the entire width of the page.

2) When you press Shift and "-" (dash) at the same time, NOT a dash is printed, but an underscore _________. Thus, you can make a continuous line of arbitrary length anywhere in the document.

Rice. 2. Thin and thick horizontal line in Word

Now we print thick horizontal line across the entire width of the page:

  • Again we find the same dash key, as well as the Shift key (left or right, as you like). Press Shift, hold and don't let go.
  • And now, from a new (!) line, click on the dash several times (for example, 3-4 times) (while not releasing Shift): ___. Release Shift.
  • Now press the Enter key. You will see a thick horizontal solid line.

Let's sum up some results in the form of a table:

(Click to enlarge) Lines in Word using the keyboard

­­­­­­­­­­­­­­­­­­­­­

II Line in Word using a table

A horizontal line can be obtained by using a table of one cell (1x1), in which only the top or bottom border is colored (will be visible), and the other three sides of the table have unpainted borders (they will be invisible).

We put the cursor in the place where the line should be. In the top menu of Word, click:

  • Insert (1 in Fig. 3),
  • Table (2 in Fig. 3),
  • One cell (3 in Fig. 3).

Rice. 3. How to insert a 1x1 table in Word (from one cell)

The result is a table of one large cell (1x1):

It remains in the 1x1 table on three sides to remove the borders. For this

  • go to the "Home" tab (1 in Fig. 4),
  • next next to "Font" we find "Paragraph" and borders (2 in Fig. 4),
  • remove all borders by clicking "No border" (3 in Fig. 4),
  • select "Upper border" or "Lower border" (4 in Fig. 4).

Rice. 4. How to remove border selection in a Word table (make borders invisible)

I show this clearly in the video (at the end of the article).

By the way, in Fig. 3 shows that there is an easier way. You can put the cursor at the beginning of the line in Word and click "Horizontal Line" (5 in Fig. 4):

III Line in Word by drawing

Insert (1 in Fig. 5) - Shapes (2 in Fig. 5) is another way to get a horizontal line in Word.

To make the line strictly horizontal, hold down the Shift key and draw the line at the same time.

Rice. 5. How to draw a line in Word

IV Line in Word using the on-screen keyboard

To find the on-screen keyboard, in the Search we enter the phrase "on-screen keyboard", more details for Windows 7, and for Windows 8.

For Windows 10, you can also find the on-screen keyboard by typing "on-screen keyboard" into the Search bar.

Rice. 6. On-screen keyboard

We will create a horizontal line in the same way as in the first version with a regular keyboard. On on-screen keyboard you will need three buttons: dash, shift and enter.

1 Dash and Enter

From a new line in Word, click on the dash several times (1 in Fig. 6) and press Enter. You will get a thin horizontal line.

2 Shift, dash and Enter

From a new line in Word, click first Shift (2 in Fig. 6), then Dash (1 in Fig. 6). Get an underline. So repeat 2 more times, and then press Enter. As a result, we will see a thick horizontal line.

While creating HTML pages design plays a significant role. Especially when we are talking about various symbols and decorative design: these little things help make the "language" of your page more accessible and clear, besides, they significantly change its perception and appearance generally. One of the most important design elements is the horizontal line, and further on we will learn in more detail how to work with it and how to make a horizontal line in html.

What is a horizontal line and why is it needed

The horizontal line in html is a page design element that performs a number of functions:

  1. decorative. Helps to add attractiveness to the page.
  2. Dividing. Contributes to the effective separation of information of different meanings.
  3. Emphasizing or emphasizing. It will draw the attention of page visitors to the necessary and most important information.

It is the horizontal line that is considered the most accessible way to implement a range of functions. It is very simple to create, and outwardly it looks very profitable. By simple changes to the html code, you can control:

  • length;
  • width;
  • color characteristics;
  • alignment on one or the other edge.

Note that the horizontal line refers to block elements. This means that it occupies a new line on the page, and the text following it will go below.

Creating a horizontal line in HTML

You can set a line using a simple tag - hr in triangular brackets. It is short for "Horisontal Rule" and sets the classic external parameters. It differs from many others in that it does not need a closing tag and is able to exist independently. You can change the external characteristics of an element using additional values ​​in the tag:

  1. Length. If you do not want the length of the line to cover the entire page, then you can set the desired size in pixels or percentages. This is done with the help of an additional word "width" in the tag and a numerical indicator of the length specified after the "=" sign in quotation marks.

It looks like this. For example, if we need a length of 100 pixels, we set the following tag: hr width="100"

  1. alignment. Alignment is possible on the left or right edges, and also in the center. This characteristic only works if you have already set width parameter, since a full-page line cannot be aligned. For alignment, we set an additional attribute in the "align" tag and add a direction to it: center - for the center, left - for the left and right - for the right alignment.

The finished tag in this case will look like this. For example, if we need to set the center alignment for a horizontal line 150 pixels long, then the finished tag will look like this: hr align="center" width="150".

Note that "align", the metric for alignment, is set to 1, even though the attribute is dependent on the width metric.

  1. Width. Optionally, you can also specify a width, creating a bold or thin underline. This criterion does not depend on anything and can be used as an independent one without specifying the length or alignment. For this, we use the size attribute on the tag and a numeric value equal to the desired width in pixels. The number is specified in quotes after the size attribute and the "=" symbol.

Thus, if we want to create a line with a width of 15 pixels, we need to create the following tag: hr size="15".

  1. Color. It is also set as an independent indicator. To change it, use the color attribute in combination with the name of the color in the form of a code or on English language. The color is specified in quotation marks after the "=" symbol.

Thus, the tag for the standard white line can be written in two ways: hr color="#FFFFFF" or hr color="white"

Black color can be created using code #000000.

  1. Put away shadow. If you need an element that does not contain a shadow, then the noshade attribute should be used in the tag. It can be used alone or in combination with other elements. The tag for the standard line using it will look like this: hr noshade

Create a horizontal line with video

And if you want to get information in a more visual format, then refer to the following video, which describes in detail the possibilities of working with a horizontal line.

Having determined the required dimensions of the horizontal line, you can arrange the pages of the site in such a way that the information is structured and visually well-formed. This makes it easier for visitors to perceive the information presented and to distinguish your site from others.

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE: