Make css underline. Underscore html or how to decorate your text for easier reading
The layout of any informative text implies the inclusion of semantic hyperlinks or anchors. These elements are added using the “a” (anchor) tag. Modern browsers by default display a similar element with Often, layout designers or web designers prefer to either change this style or remove it altogether.
In some cases this is really necessary. For example, in a dense link block, where unnecessary design will only overload the perception and make the document difficult to read. However, in some cases it is appropriate to maintain a distinction between text and links. If the site design completely excludes such formatting, then it is worth using any other type of highlighting of such elements. The most common type of differentiation today is the color contrast of anchors in the text. It's effective. The only slight disadvantage of this option will be the problem of highlighting text by people who cannot perceive different colors (color blindness). But this is such a low percentage of users that it can be neglected.
If, after all, it was decided to remove the underlining of links, then you will need some knowledge of the structure of the Internet page, namely CSS.
Remove link underlining from entire site
For a person who is well versed in web design and in particular, it will not be difficult. To do this, you just need to find and open the file in the site files that is responsible for the styling. Usually it lies in root directory and has a .css extension. You can remove underlining from links using this simple code:
text-decoration: none;
This small line will completely remove the underlining of all elements written using the “a” tag throughout the entire site.
But what if you don't have access to CSS file?
In this case, it is advisable to use tag Style at the beginning of the document. Works the same as a CSS file. In order to apply styles, it is necessary at the very beginning of the document (or HTML pages) add a construction in which the usual CSS rules styles.
These styles only apply to a specific page. They will not apply to other sections or documents of the site.
Remove link underline on hover
But what if you need to remove the link underline on hover? CSS can help us in this case too. The code will look like this:
text-decoration: none;
It is the pseudo-class “:hover” that is responsible for decorating elements when hovering over them.
By combining these two options, we can make the link underline appear only on hover, otherwise it will look like regular text:
text-decoration: none;
text-decoration: underline;
Using Identifiers and Classes
As you can see from the above, changing the styling of an element on a website or HTML document is quite easy. The disadvantages of such options are the impossibility of selectively applying styles: not to the entire site or document, but to a specific link.
There are several options to solve this problem.
You can remove the underlining of links inline. Although this is strictly not recommended from the point of view of optimizing the site.
To do this, you need to specify the Style parameter directly in the link tag:
The second option is more acceptable.
We introduce an additional class or id into the element and assign the styles we need to these selectors:
A class is written with a dot before its name:
None_decoration(
text-decoration: none;
The identifier is indicated by the # sign:
#none_decoration(
text-decoration: none;
This rule applies to both the CSS file and the Style tag
Changing the display style of links in text
This is also quite simple to do:
color :*specify the desired color in any format (*red, #c2c2c2, rgb (132, 33, 65)*)*;
Similar styling is applied according to the same rules as described for de-underlining a link. CSS rules in in this case identical. Changing the link color and removing the underline can be applied as a separate styling (then the link will remain underlined, but will change the color from the standard blue to the color you want).
Replacing standard styling
One last note. Instead of undoing the underline CSS links makes it possible to replace standard design values. To do this, just substitute the following values into the text-decoration construct:
text-decoration-style:
- If you need a solid line, specify the value solid.
- For a wavy line - wavy.
- Double line - respectively double.
- The line can be replaced with a sequence of dots - dotted.
- Underline a word as a dotted line - dashed
You can also change the position of the line relative to the text:
The line-text-decoration-line construct can take the following values:
And the color (not to be confused with the text color!):
text-decoration-line: (any color in any format * red, #c2c2c2, rgb (132, 33, 65)*).
For convenience, all three positions can be written together in the construction:
text-decoration: red, line-through, wavy.
With the advent of CSS3, HTML5 and the inclusion of web fonts, sites have become dynamic, beautiful and more technologically advanced in the development process. Many people do not like to underline links and to some extent I understand them. Quite thick lines, though, help the user navigate the site and distinguish a link from regular text. But they make it somewhat difficult to read.
With the advent of the format RGBA(Red Green Blue Alpha) in CSS3 can be considered this problem solved. By using an advanced color representation format, web designers now have the ability to use alpha transparency for color.
Unlike opacity properties it can be applied to the font and borders and to the background of the block without changing the transparency of the block contents. RGBA color values are an extension of RGB color values with only an alpha channel - which determines the opacity of an object.
Syntax
color: rgba(0,96,160); / * blue color */ color: rgba (0,96,160,0.2 ); / * blue color with transparency */Meaning RGBA colors given by: RGBA (red, green, blue, alpha).
The alpha parameter represents a number from 0.0(completely transparent) up to 1.0(completely opaque).
Compatibility
RGBA color values are supported by browsers: IE9+, Firefox 3+, Chrome, Safari, and Opera 10+.
Who implemented
Lebedev Studio, Artyom Gorbunov Design Bureau, Ilya Birman immediately took advantage of this opportunity... On their sites, the underlining of links remained, but it became more elegant.
patpitchaya/By default, browsers use certain sets CSS styles to specific HTML elements. For hyperlinks, these default styles specify that any link text appears in blue with CSS underline . This is done so that site visitors can easily determine that this text is a link. Many web designers don't pay attention to these default styles, especially underline. Luckily, CSS makes it easy to change appearance hyperlinks.
Remove link underlining
Underlined text may be more difficult to read than normal text. Many designers simply don't pay enough attention to this. But you can remove the underline completely. For this we will use the CSS text-decoration property. Here's the CSS code you can use to do this:
a (text-decoration: none; )
With this line of code you can remove the CSS underline style of all links.
Caveat about removing underscores
Whether you like underlining or not, there is no denying that it allows you to indicate the connection of text with a link. If you remove the underline or change the blue color of the links, you need to provide instead styles that allow the text of the links to stand out. This will make the interaction of visitors with the site intuitive.
Don't underline text that isn't linked to the link
Do not underline text that is not a link. People are used to the fact that underlined text ( using CSS underline color) is a link. If you underline content to focus attention on it ( instead of putting it in bold or italics), you are misleading site users.
Change the solid underline to dots or dashes
If you want to keep the underlining of links, but change the default style (line " solid "), this can be done as follows. Use dots instead of a solid line. To do this, you need to remove the underline and replace it with the border-bottom property:
a ( text-decoration: none; border-bottom:1px dotted; )
Since standard CSS text decoration We have removed underline, only a line of dots will be displayed:
The same can be done to get a dotted underline. Just change border-bottom to dashed :
a ( text-decoration: none; border-bottom:1px dashed; )
Change the underline color
Another way to draw users' attention to links is to change the underline color. Don't forget that the CSS text underline color must match the color scheme you're using:
a ( text-decoration: none; border-bottom:1px solid red; )
Double underscore
The trick to creating a double underline is to change the border width. If you create a 1 pixel wide border, the result will be two underlines that look like one:
a ( text-decoration: none; border-bottom:3px double; )
You can also use the default underscore to create an alternative double underscore. For example, to make one of the lines double:
a ( border-bottom:1px double; )
Don't forget about different link states
You can also use border-bottom to various conditions links. Using the :hover pseudo-class will help improve the user experience. To create a second dotted underline that appears when you hover over a link, use the following code and disable the CSS text decoration underline :
a ( text-decoration: none; ) a:hover ( border-bottom:1px dotted; )
Translation of the article " How to Change Link Underlines on a Webpage"was prepared by the friendly project team.
Good bad
Underline for block elements like tag
can be done in two ways. For example, set the line under the text to the entire width of the block, regardless of the volume of the text. And also underline only the text. Next we will consider both options.
Line under the text across the entire width of the block
To create a line under the text, you should add the style property border-bottom to the element; its value is both the thickness of the line, its style and color (example 1).
Example 1. Full width line
HTML5 CSS 2.1 IE Cr Op Sa Fx
Example text
The distance from the line to the text can be adjusted by adding the padding-bottom property to the H1 selector. Result this example shown in Fig. 1.
Underline text
To underline just the text, you need to use the text-decoration property with the value underline , again adding it to the H1 selector (example 2).
Example 2. Line to text width
HTML5 CSS 2.1 IE Cr Op Sa Fx
Example text
The black headline attracts attention even though it is black and not white.
The result of this example is shown in Fig. 2.
When using the text-decoration property, the line is rigidly attached to the text, so its position and style cannot be determined.
On this page you will find examples on how to change HTML links when CSS help, which allows you to make them block links, icon links, without underlining, with rounded corners, change the distance between them and much more. In the future, based on these examples, you can create various options navigation menus for site.
Before you start studying the examples, I want to make a small clarification. In all examples, for greater clarity, a CSS pseudo-class will be used, which is used to change the styles of links when the mouse cursor hovers over them. It must be said that this practice is common and is used to one degree or another on almost all Internet sites.
In this example, we will remove the underline from the links, and then add or remove them on mouseover.
HTML and CSS example: how to remove and add underlines from links
Description of the example
- Default is all popular browsers add underlining to links, which is adjustable CSS property. That is, by default this property, for links, has the value underline . Using this knowledge, we change the underlining of links in their different states.
Initially, the underlining of links is a solid thin line, pressed almost closely to the text. And in most cases, this option is quite sufficient. However, sometimes a design requires that links be underlined with a dotted line rather than a solid line, or that the distance from the underline to the links be greater than the standard, or that the underline itself be bolder. And sometimes you need to make some kind of exotic underlining, for example, with a wavy or multi-colored line. All these options will be discussed in this example.
HTML and CSS Example: Dotted Link Underline
Description of the example
- First, we remove the standard underline from all links, since we will use non-standard methods. Then we add a bottom border to the first link using the CSS property and make it dashed. This will be our underscore. To remove the underline when you hover over a link, we use a pseudo-class and make the background of the frame the same as the background of the page, that is, we simply hide it. In theory, it would be better to make the background of the frame transparent, but IE6 misunderstands this meaning.
- With the second link we do the same as with the first, but we just draw a solid line. To increase the distance from the text to the underline, we give the link a small bottom margin using the CSS property.
- Our third link has a multi-colored underline, so we will add it using background image. For this we use a small image, which we connect via CSS. Position the background at the bottom of the link (0 100%) and allow it to be duplicated only horizontally (repeat-x). The underline is ready, but it is too close to the text; to fix this, we add a small indent to the link below. That's it.
- In the old IE6 and IE7, there may be problems with displaying the underscore on the first and second links. To fix this, add the zoom :1 property, which includes the so-called layout. This property is invalid and only these browsers understand it, so it is better to enable it conditional comments.
Very often, to create a menu, you need to make not just text links, but block links, in which the active area will be both the text itself and a certain area around it.
Description of the example
- To create block links, we use the CSS property :block, which turns them into block elements that create a line break before and after them. If line breaks are not needed, you can replace the value with inline-block .
- Since our links are now blocks, if necessary, we can change their width (CSS) or height (CSS).
- In this example, we do not specify the height of the links at all, but simply give them internal padding (CSS), which expands the blocks.
Description of the example
- Everything is very simple - using the CSS property we add the desired frame to the links under the cursor. However, please note that we add exactly the same frame to regular links, but we make it the same color as the page background. That is, we simply hide the frame for the time being. This is done so that when you hover the mouse cursor, the links do not start to “jump” due to the drawing of the frame.
Instead of making the border color match the background of the page, it could be set to transparent and made transparent, but as I said, IE6 does not handle it correctly.
HTML and CSS Example: Creating 3D Links
Description of the example
- Using the CSS property we add frames to the links, and with the help we set their color. In this case, for the left and upper borders we indicate light shade colors, and for the bottom and right - dark. It is thanks to this distribution of colors that we get links that look like three-dimensional buttons.
- To make it seem like the buttons are being pressed when you hover the mouse cursor, we invert the border colors of links with a pseudo-class. For an additional click effect, set the relative positioning (CSS :relative) and make a one-pixel upward offset (CSS :-1px).
- Well, to make everything absolutely beautiful, we set the text and background color of the links under the cursor a little darker than the usual ones. Ready.
In this example, we will make links with icons that will contain not only images of these icons, but also text under them. However, in the future you can easily change them and leave, for example, only icons.
Before starting work, we will prepare several images of icons, in two sets - for regular links and links under the mouse cursor. The second set should be externally different from the first, with us this is expressed in the color palette.
In this example, we will round the corners of the links using one of the methods rounding corners, described in the next subsection. We will not consider the option using CSS 3, since everything is very simple there, but it would be better to make roundings using images.
To do this, first we will cut out several blank images in two sets - for regular links and links under the cursor. For us, it will differ in the presence/absence of shadows in the images.
absolute positioning*/ top: 0; /* zero top offset */ ) .links:before ( content: url("images/left_bok.png"); /* left side image */ left: 0; /* zero left offset */ ) .links:hover: before ( content: url("images/left_bok_hover.png"); /* image of the left side under the mouse cursor */ ) .links:after ( content: url("images/right_bok.png"); /* image of the right side * / right: 0; /* zero offset to the right */ ) .links:hover:after ( content: url("images/right_bok_hover.png"); /* image of the right side under the mouse cursor */ )