CSS Text and Layout

CSS Text and Layout

·

4 min read

CSS Text and Layout

A website's overall appearance and feel can be greatly influenced by two key elements of web design: CSS Text and Layout. Web designers may build appealing, well-organized websites that are both aesthetically pleasant and user-friendly by utilizing CSS Text and Layout.

Its primary function when it comes to CSS Text is to specify how text should be displayed on a web page. Setting text's alignment, style, size, color, and font are all examples of this. Designers can customize the look and feel of their website by altering the text settings to give it a distinctive appearance.

Contrast Bootstrap UI Kit

Text Color

The color property is used to set the color of the text. The color is specified by:

  • A color name - like "red"

  • A HEX value - like "#ff0000"

  • An RGB value - like "rgb(255,0,0).

The default text color for a page is defined in the body selector.

body {  color: blue;}h1 {  color: green;}

Text Alignment

The text-align property is used to set the horizontal alignment of a text. A text can be left or right aligned, centered, or justified.

h1 {  text-align: center;}h2 {  text-align: left;}h3 {  text-align: right;}div {  text-align: justify;}

When the text-align property is set to "justify", each line is stretched so that every line has equal width, and the left and right margins are straight (like in magazines and newspapers).

Text Direction

The direction and unicode-bidi properties can be used to change the text direction of an element

p {  direction: rtl;  unicode-bidi: bidi-override;}

Vertical Alignment: The vertical-align property sets the vertical alignment of an element.

img.top {  vertical-align: top;}img.middle {  vertical-align: middle;}img.bottom {  vertical-align: bottom;}

Text Decoration

The text-decoration property is used to set or remove decorations from text. The value text-decoration: none; is often used to remove underlines from links:

a {  text-decoration: none;}h1 {  text-decoration: overline;}h2 {  text-decoration: line-through;}h3 {  text-decoration: underline;}

Text Transformation

The text-transform property is used to specify uppercase and lowercase letters in a text. It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word

p.uppercase {  text-transform: uppercase;}p.lowercase {  text-transform: lowercase;}p.capitalize {  text-transform: capitalize;}

Text Indentation

The text-indent property is used to specify the indentation of the first line of a text

p {  text-indent: 50px;}

Letter Spacing

The letter-spacing property is used to specify the space between the characters in a text.

h1 {  letter-spacing: 3px;}h2 {  letter-spacing: -3px;}

Line Height

The line-height property is used to specify the space between lines

p.small {  line-height: 0.8;}p.big {  line-height: 1.8;}

Word Spacing

The word-spacing property is used to specify the space between the words in a text.

h1 {  word-spacing: 10px;}h2 {  word-spacing: -5px;}

White Space

The white-space property specifies how white-space inside an element is handled.

p {  white-space: nowrap;}

This shows how disable text wrapping inside an element.

Text Shadow

The text-shadow property adds shadow to text.

h1 {  text-shadow: 2px 2px 5px red;}

In this code, you add shadow, color and a blur effect(5px). Using width, max-width and margin: auto; As mentioned in the previous chapter, a block-level element always takes up the full width available (stretches out to the left and right as far as it can).

Setting the width of a block-level element will prevent it from stretching out to the edges of its container. Then, you can set the margins to auto, to horizontally center the element within its container. The element will take up the specified width, and the remaining space will be split equally between the two margins.

Using max-width will improve the browser's handling of small windows. This is important when making a site usable on small devices:

Here is a code for two different divs that shows the function of the max-width.

div.ex1 {  width: 500px;  margin: auto;  border: 3px solid #73ad21;}div.ex2 {  max-width: 500px;  margin: auto;  border: 3px solid #73ad21;}

Web designers can produce a beautiful webpage that is both user-friendly and visually appealing by integrating CSS Text and Layout. Utilizing these two elements, web designers can produce webpages that are not only aesthetically beautiful but also successful in communicating the content or goal of the page. The effective structuring of content made possible by the usage of CSS Text and Layout can also improve user experience.

Conclusion

In conclusion, CSS Text and Layout are two significant web design elements that can be used to produce a visually appealing and carefully organized webpage. Designers can produce a web page that is both user-friendly and successful in communicating the content or goal of the website by integrating the two elements.

Web designers can develop webpages that are both aesthetically beautiful and successful in communicating the message or goal of the page by utilizing both CSS Text and Layout.