Rectangle 27 36

Excerpt from the "Block-level, non-replaced elements in normal flow" s...

Margins are for moving an element in from the wrapper, not expanding the wrapper outwards.

This behavior is consistent with specifying a width in addition to a horizontal margin anywhere in the document. To break it down, consider the following snippet, where I specificity a wrapper without an overflow property, and the margin does not expand the wrapper element.

<div class="outer">
    <div class="inner">
        
    </div>
</div>

As you can see, the margin did not cause the wrapper to expand in size, the element just continued to overflow. This behavior is documented under Visual formatting model details of the is documented in the CSS 2.1 specification.

The following constraints must hold among the used values of the other properties:

If all of the above have a computed value other than 'auto', the values are said to be "over-constrained" and one of the used values will have to be different from its computed value. If the 'direction' property of the containing block has the value 'ltr', the specified value of 'margin-right' is ignored and the value is calculated so as to make the equality true. If the value of 'direction' is 'rtl', this happens to 'margin-left' instead.

That excerpt is quite dense, so to simply, let's ignore the width of border and padding, both of which are 0, leaving us with width, margin-left, and margin-right.

Now since the you have a fixed width and values for margin-left and margin-right, the values are "over-constrained". Now in our example, since the direction is ltr by default, the margin-right is forced to compensate.

To see the effects of the direction, let's try adding a dir="rtl" attribute to the wrapper element.

body {
    padding: 20px;
}
.outer {
    width: 400px;
    border: 1px solid black;
}
.inner {
    width: 400px;
    height: 40px;
    margin: 0 20px;
    background: grey;
}
<div class="outer" dir="rtl">
    <div class="inner">
        
    </div>
</div>

Now the element is overflowing to the left. Let's see if this dir="rtl" attribute has the same effect on your overflow: scroll example.

#outer {
    border: 1px solid #00F;
    width: 200px;
    height: 100px;
    overflow: scroll;
}
#inner {
    border: 1px solid #F0F;
    margin: 25px;
    width: 400px;
    height: 200px;
}
<div id="outer" dir="rtl">
    <div id="inner">
    
    </div>
</div>

Yep, it does. The margin is now missing on the left, rather than the right.

Mainly because the specification does not say it should. Let's take a look at the CSS 2 specification for the overflow property.

Whenever overflow occurs, the 'overflow' property specifies whether a box is clipped to its padding edge, and if so, whether a scrolling mechanism is provided to access any clipped out content.

See how it specifically says "clipped out content". For an explanation of "content", lets refer to the following graphic from the CSS 2 specification.

As we can see, the margin is separate from the content. However, at this point it's worth noting that padding and borders are included in the scrolling area, so when the the spec says "content", it is likely referring to border-box, or at least, that seems to be how it was interpreted.

Basically, margins behave differently on inline-block elements, because they are content level rather than block level, and they do not have a concept of being "over-constrained".

html - CSS Right Margin Does Not Work Inside a Div With Overflow Scrol...

html css scroll overflow margin
Rectangle 27 6

res/values/strings.xml (the string resource as HTML)

Android does not have a specification to indicate the type of resource string (e.g. text/plain or text/html). There is a workaround, however, that will allow the developer to specify this within the XML file.

  • Define a custom attribute to specify that the android:text attribute is html.
  • Use a subclassed TextView.

Once you define these, you can express yourself with HTML in xml files without ever having to call setText(Html.fromHtml(...)) again. I'm rather surprised that this approach is not part of the API.

This solution works to the degree that the Android studio simulator will display the text as rendered HTML.

<resources>
<string name="app_name">TextViewEx</string>
<string name="string_with_html"><![CDATA[
       <em>Hello</em> <strong>World</strong>!
 ]]></string>
</resources>

Declare the custom attribute namespace, and add the android_ex:isHtml attribute. Also use the subclass of TextView.

<RelativeLayout
...
xmlns:android_ex="http://schemas.android.com/apk/res-auto"
...>

<tv.twelvetone.samples.textviewex.TextViewEx
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/string_with_html"
    android_ex:isHtml="true"
    />
 </RelativeLayout>
<resources>
<declare-styleable name="TextViewEx">
    <attr name="isHtml" format="boolean"/>
    <attr name="android:text" />
</declare-styleable>
</resources>
package tv.twelvetone.samples.textviewex;

 import android.content.Context;
 import android.content.res.TypedArray;
 import android.support.annotation.Nullable;
 import android.text.Html;
 import android.util.AttributeSet;
 import android.widget.TextView;

public TextViewEx(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextViewEx, 0, 0);
    try {
        boolean isHtml = a.getBoolean(R.styleable.TextViewEx_isHtml, false);
        if (isHtml) {
            String text = a.getString(R.styleable.TextViewEx_android_text);
            if (text != null) {
                setText(Html.fromHtml(text));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        a.recycle();
    }
}
}

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 6

res/values/strings.xml (the string resource as HTML)

Android does not have a specification to indicate the type of resource string (e.g. text/plain or text/html). There is a workaround, however, that will allow the developer to specify this within the XML file.

  • Define a custom attribute to specify that the android:text attribute is html.
  • Use a subclassed TextView.

Once you define these, you can express yourself with HTML in xml files without ever having to call setText(Html.fromHtml(...)) again. I'm rather surprised that this approach is not part of the API.

This solution works to the degree that the Android studio simulator will display the text as rendered HTML.

<resources>
<string name="app_name">TextViewEx</string>
<string name="string_with_html"><![CDATA[
       <em>Hello</em> <strong>World</strong>!
 ]]></string>
</resources>

Declare the custom attribute namespace, and add the android_ex:isHtml attribute. Also use the subclass of TextView.

<RelativeLayout
...
xmlns:android_ex="http://schemas.android.com/apk/res-auto"
...>

<tv.twelvetone.samples.textviewex.TextViewEx
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/string_with_html"
    android_ex:isHtml="true"
    />
 </RelativeLayout>
<resources>
<declare-styleable name="TextViewEx">
    <attr name="isHtml" format="boolean"/>
    <attr name="android:text" />
</declare-styleable>
</resources>
package tv.twelvetone.samples.textviewex;

 import android.content.Context;
 import android.content.res.TypedArray;
 import android.support.annotation.Nullable;
 import android.text.Html;
 import android.util.AttributeSet;
 import android.widget.TextView;

public TextViewEx(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextViewEx, 0, 0);
    try {
        boolean isHtml = a.getBoolean(R.styleable.TextViewEx_isHtml, false);
        if (isHtml) {
            String text = a.getString(R.styleable.TextViewEx_android_text);
            if (text != null) {
                setText(Html.fromHtml(text));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        a.recycle();
    }
}
}

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 6

res/values/strings.xml (the string resource as HTML)

Android does not have a specification to indicate the type of resource string (e.g. text/plain or text/html). There is a workaround, however, that will allow the developer to specify this within the XML file.

  • Define a custom attribute to specify that the android:text attribute is html.
  • Use a subclassed TextView.

Once you define these, you can express yourself with HTML in xml files without ever having to call setText(Html.fromHtml(...)) again. I'm rather surprised that this approach is not part of the API.

This solution works to the degree that the Android studio simulator will display the text as rendered HTML.

<resources>
<string name="app_name">TextViewEx</string>
<string name="string_with_html"><![CDATA[
       <em>Hello</em> <strong>World</strong>!
 ]]></string>
</resources>

Declare the custom attribute namespace, and add the android_ex:isHtml attribute. Also use the subclass of TextView.

<RelativeLayout
...
xmlns:android_ex="http://schemas.android.com/apk/res-auto"
...>

<tv.twelvetone.samples.textviewex.TextViewEx
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/string_with_html"
    android_ex:isHtml="true"
    />
 </RelativeLayout>
<resources>
<declare-styleable name="TextViewEx">
    <attr name="isHtml" format="boolean"/>
    <attr name="android:text" />
</declare-styleable>
</resources>
package tv.twelvetone.samples.textviewex;

 import android.content.Context;
 import android.content.res.TypedArray;
 import android.support.annotation.Nullable;
 import android.text.Html;
 import android.util.AttributeSet;
 import android.widget.TextView;

public TextViewEx(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextViewEx, 0, 0);
    try {
        boolean isHtml = a.getBoolean(R.styleable.TextViewEx_isHtml, false);
        if (isHtml) {
            String text = a.getString(R.styleable.TextViewEx_android_text);
            if (text != null) {
                setText(Html.fromHtml(text));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        a.recycle();
    }
}
}

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 3

I've solved it using a WYSIWYG HTML editor. However, I'm facing a new problem, if anyone could help, that'd be great!

c# - HTML Formatting in RichTextBox - Stack Overflow

c# html xml formatting richtextbox
Rectangle 27 436

Just in case anybody finds this, there's a nicer alternative that's not documented (I tripped over it after searching for hours, and finally found it in the bug list for the Android SDK itself). You CAN include raw HTML in strings.xml, as long as you wrap it in

<![CDATA[ ...raw html... ]]>
<string name="nice_html">
<![CDATA[
<p>This is a html-formatted string with <b>bold</b> and <i>italic</i> text</p>
<p>This is another paragraph of the same string.</p>
]]>
</string>

Then, in your code:

TextView foo = (TextView)findViewById(R.id.foo);
foo.setText(Html.fromHtml(getString(R.string.nice_html)));

IMHO, this is several orders of magnitude nicer to work with :-)

Just to add, you can also backslash-escape apostrophes/single-quotes inside the CDATA block, so you can have things like <b>can\'t</b> instead of the infinitely-uglier <b>cant</b>

Does this still work? I just tried it and it literally displays the <p> and </p>.

Html.fromHtml(getString(R.string.nice_html))

Is there a way to avoid "Html.fromHtml" ?

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 434

Just in case anybody finds this, there's a nicer alternative that's not documented (I tripped over it after searching for hours, and finally found it in the bug list for the Android SDK itself). You CAN include raw HTML in strings.xml, as long as you wrap it in

<![CDATA[ ...raw html... ]]>
<string name="nice_html">
<![CDATA[
<p>This is a html-formatted string with <b>bold</b> and <i>italic</i> text</p>
<p>This is another paragraph of the same string.</p>
]]>
</string>

Then, in your code:

TextView foo = (TextView)findViewById(R.id.foo);
foo.setText(Html.fromHtml(getString(R.string.nice_html)));

IMHO, this is several orders of magnitude nicer to work with :-)

Just to add, you can also backslash-escape apostrophes/single-quotes inside the CDATA block, so you can have things like <b>can\'t</b> instead of the infinitely-uglier <b>cant</b>

Does this still work? I just tried it and it literally displays the <p> and </p>.

Html.fromHtml(getString(R.string.nice_html))

Is there a way to avoid "Html.fromHtml" ?

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 434

Just in case anybody finds this, there's a nicer alternative that's not documented (I tripped over it after searching for hours, and finally found it in the bug list for the Android SDK itself). You CAN include raw HTML in strings.xml, as long as you wrap it in

<![CDATA[ ...raw html... ]]>
<string name="nice_html">
<![CDATA[
<p>This is a html-formatted string with <b>bold</b> and <i>italic</i> text</p>
<p>This is another paragraph of the same string.</p>
]]>
</string>

Then, in your code:

TextView foo = (TextView)findViewById(R.id.foo);
foo.setText(Html.fromHtml(getString(R.string.nice_html)));

IMHO, this is several orders of magnitude nicer to work with :-)

Just to add, you can also backslash-escape apostrophes/single-quotes inside the CDATA block, so you can have things like <b>can\'t</b> instead of the infinitely-uglier <b>cant</b>

Does this still work? I just tried it and it literally displays the <p> and </p>.

Html.fromHtml(getString(R.string.nice_html))

Is there a way to avoid "Html.fromHtml" ?

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 3

I've solved it using a WYSIWYG HTML editor. However, I'm facing a new problem, if anyone could help, that'd be great!

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

c# - HTML Formatting in RichTextBox - Stack Overflow

c# html xml formatting richtextbox
Rectangle 27 114

Remember to have the HTML code selected before you do this.

Hey there, I used that and it works nicely with only HTML. With django tags however seems to just erase them or not format them properly. It's the closest so far. Ta for the tip.

For those who download the new Notepad++. TextFX is not bundled anymore. You'll need to go to Plugins > Plugin Manager > Show Plugin Manager and download TextFX from there. On top of that you'll probably find that TextFX can't find libTidy.dll. To fix that you can do this stackoverflow.com/questions/6985637/ After all of that you should be able to TextFX -> HTML Tidy -> Tidy: Reindent XML as @gablin described.

tidy
unicode\plugins\Config
C:\Program Files\Notepad++\plugins\Config

In my case there were no plugins listed under the 'Available' tab of the 'Plugin Manager'. To fix it I had to amend firewall rules for Notepad++ and the 'Plugin Manager' then displayed the full list of downloadable plugins as expected.

Plugins > Plugin Manager > Show Plugin Manager
Tidy2

html - Formatting code in Notepad++ - Stack Overflow

html notepad++ code-formatting
Rectangle 27 27

You can use Html.TagHandler.

public class UlTagHandler implements Html.TagHandler{
    @Override
    public void handleTag(boolean opening, String tag, Editable output,
                          XMLReader xmlReader) {
            if(tag.equals("ul") && !opening) output.append("\n");
            if(tag.equals("li") && opening) output.append("\n\t");
    }
}

and

textView.setText(Html.fromHtml(myHtmlText, null, new UlTagHandler()));

nice one! just the indenting issue on bullets with multiple lines of text

html - Show
  • in android textview - Stack Overflow

android html formatting textview
Rectangle 27 72

there is such a plugin as UniversalIndentGUI, it can be installed right from the plugin manager and has possibilities to reindent the most used programming languages.

+1 This works great! Install the UniversalIndentGUI plugin and press Ctrl+Alt+Shift+J to format.

Thanks this works great. Is there a way to automatically format the code when you save? Right now, when I check enable autoupdate text, it doesn't update when I save or exit the file.

Plugin downloaded and task done in less than 30s. Thanks.

It seems worth noting that "the plugin manager" is itself a plug-in, yes? Being unfamiliar with Notepad++, it took a fair amount of failed menu searching followed by Googling to understand this. Its installation process needs to be factored into the "simplicity" of this solution if one is starting from scratch.

though a plugin, it comes preinstalled in default Notepad++ installers

html - Formatting code in Notepad++ - Stack Overflow

html notepad++ code-formatting
Rectangle 27 25

You can use Html.TagHandler.

public class UlTagHandler implements Html.TagHandler{
    @Override
    public void handleTag(boolean opening, String tag, Editable output,
                          XMLReader xmlReader) {
            if(tag.equals("ul") && !opening) output.append("\n");
            if(tag.equals("li") && opening) output.append("\n\t");
    }
}

and

textView.setText(Html.fromHtml(myHtmlText, null, new UlTagHandler()));

nice one! just the indenting issue on bullets with multiple lines of text

html - Show
  • in android textview - Stack Overflow

android html formatting textview
Rectangle 27 109

As the top answer here is suggesting something wrong (or at least too complicated), I feel this should be updated, although the question is quite old:

When using String resources in Android, you just have to call getString(...) from Java code or use android:text="@string/..." in your layout XML.

Even if you want to use HTML markup in your Strings, you don't have to change a lot:

The only characters that you need to escape in your String resources are:

\"
\'
  • ampersand: & becomes or
<string name="my_string"><b>Hello World!</b> This is an example.</string>

However, to be sure, you should only use <b>, <i> and <u> as they are listed in the documentation.

If you want to use your HTML strings from XML, just keep on using android:text="@string/...", it will work fine.

The only difference is that, if you want to use your HTML strings from Java code, you have to use getText(...) instead of getString(...) now, as the former keeps the style and the latter will just strip it off.

It's as easy as that. No CDATA, no Html.fromHtml(...).

You will only need Html.fromHtml(...) if you did encode your special characters in HTML markup. Use it with getString(...) then. This can be necessary if you want to pass the String to String.format(...).

This is all described in the docs as well.

There is no difference between getText(...) with unescaped HTML (as I've proposed) or CDATA sections and Html.fromHtml(...).

See the following graphic for a comparison:

getResources().getText(R.string.codename)

In order to help better, I'd need to see the Java/XML excerpts. But as I've written: You are only sure if you're using <b>, <i>, <u>. Other tags are not always supported.

Your answer works and is simple. Just put your string in strings.xml, with the desired html tags, and reference it from your layout xml file. I used the <sup> tag.

Yours is another solution, not an alternative to the other because it doesn't support all tags, like the other does. I fail to see any advantage in this solution when the other is very simple.

As I experienced using "CDATA" have a problem, something like this for example: <![CDATA[...HTML...]]> that have 22 letters and html part have 10. so if you use HTML.fromhtml(getstring(...)) your text will be show correctly but text's content need 22 letters spaces. I used in listview and seen weedy spaces. so gettext() is BETTER.

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 109

As the top answer here is suggesting something wrong (or at least too complicated), I feel this should be updated, although the question is quite old:

When using String resources in Android, you just have to call getString(...) from Java code or use android:text="@string/..." in your layout XML.

Even if you want to use HTML markup in your Strings, you don't have to change a lot:

The only characters that you need to escape in your String resources are:

\"
\'
  • ampersand: & becomes or
<string name="my_string"><b>Hello World!</b> This is an example.</string>

However, to be sure, you should only use <b>, <i> and <u> as they are listed in the documentation.

If you want to use your HTML strings from XML, just keep on using android:text="@string/...", it will work fine.

The only difference is that, if you want to use your HTML strings from Java code, you have to use getText(...) instead of getString(...) now, as the former keeps the style and the latter will just strip it off.

It's as easy as that. No CDATA, no Html.fromHtml(...).

You will only need Html.fromHtml(...) if you did encode your special characters in HTML markup. Use it with getString(...) then. This can be necessary if you want to pass the String to String.format(...).

This is all described in the docs as well.

There is no difference between getText(...) with unescaped HTML (as I've proposed) or CDATA sections and Html.fromHtml(...).

See the following graphic for a comparison:

getResources().getText(R.string.codename)

In order to help better, I'd need to see the Java/XML excerpts. But as I've written: You are only sure if you're using <b>, <i>, <u>. Other tags are not always supported.

Please provide a bit more context: What is the content of the codename string resource? It should include unescaped HTML tags. And where are you using the result of getText(...) then?

yes, actually It does not work fom me too. It strips away the <a> html tag

Your answer works and is simple. Just put your string in strings.xml, with the desired html tags, and reference it from your layout xml file. I used the <sup> tag.

Yours is another solution, not an alternative to the other because it doesn't support all tags, like the other does. I fail to see any advantage in this solution when the other is very simple.

As I experienced using "CDATA" have a problem, something like this for example: <![CDATA[...HTML...]]> that have 22 letters and html part have 10. so if you use HTML.fromhtml(getstring(...)) your text will be show correctly but text's content need 22 letters spaces. I used in listview and seen weedy spaces. so gettext() is BETTER.

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 109

As the top answer here is suggesting something wrong (or at least too complicated), I feel this should be updated, although the question is quite old:

When using String resources in Android, you just have to call getString(...) from Java code or use android:text="@string/..." in your layout XML.

Even if you want to use HTML markup in your Strings, you don't have to change a lot:

The only characters that you need to escape in your String resources are:

\"
\'
  • ampersand: & becomes or
<string name="my_string"><b>Hello World!</b> This is an example.</string>

However, to be sure, you should only use <b>, <i> and <u> as they are listed in the documentation.

If you want to use your HTML strings from XML, just keep on using android:text="@string/...", it will work fine.

The only difference is that, if you want to use your HTML strings from Java code, you have to use getText(...) instead of getString(...) now, as the former keeps the style and the latter will just strip it off.

It's as easy as that. No CDATA, no Html.fromHtml(...).

You will only need Html.fromHtml(...) if you did encode your special characters in HTML markup. Use it with getString(...) then. This can be necessary if you want to pass the String to String.format(...).

This is all described in the docs as well.

There is no difference between getText(...) with unescaped HTML (as I've proposed) or CDATA sections and Html.fromHtml(...).

See the following graphic for a comparison:

getResources().getText(R.string.codename)

In order to help better, I'd need to see the Java/XML excerpts. But as I've written: You are only sure if you're using <b>, <i>, <u>. Other tags are not always supported.

Your answer works and is simple. Just put your string in strings.xml, with the desired html tags, and reference it from your layout xml file. I used the <sup> tag.

Yours is another solution, not an alternative to the other because it doesn't support all tags, like the other does. I fail to see any advantage in this solution when the other is very simple.

As I experienced using "CDATA" have a problem, something like this for example: <![CDATA[...HTML...]]> that have 22 letters and html part have 10. so if you use HTML.fromhtml(getstring(...)) your text will be show correctly but text's content need 22 letters spaces. I used in listview and seen weedy spaces. so gettext() is BETTER.

android - Set TextView text from html-formatted string resource in XML...

html android formatting textview
Rectangle 27 2

CSS (formatting for illustration purposes and fixed width)

Below follows what I think is the best way to solve this. I will divide it up in whether or not it is a background image or color we are looking to apply accross the full width.

.content{
    padding:20px;
    border: 1px solid #269abc;
    background:#d6ec94;
}
[class*="col-"] {
    padding-top:10px; /* 15px side paddings automatically applied */
    padding-bottom:10px;
    border: 1px solid grey;
    background: transparent;
}
.fixed-width {
    display:inline-block;
    float:none;
    width: 300px;
}

The key here is the fixed-width class, and follows your approach (2). The other styles are just so you can try it and easily see how it works.

#one {
    background-image: url([insert-url]);
    background-repeat: no-repeat;
    background-size: contain;
    height:500px;
}

The key here is the background-size: contain element. As long as the width/height ratio of your background image is larger than the section's ratio, the image will fill the full background.

#two {
    background-color: grey;
    height:500px;
}
background-color
<section id="one">
    <div class="container">
        <div class="row text-center">

            <div class="col-sm-4 fixed-width">
                <div class="content">HERE</div>
            </div>

            <div class="col-sm-4 fixed-width">
                <div class="content">HERE</div>
            </div>

            <div class="col-sm-4 fixed-width">
                <div class="content">HER</div>
            </div>

        </div>
    </div>
</section>

As seen, by adding a <section> around the container, you can apply the background image or color to the full width of the page.

html - Bootstrap 3.0: Full-Width Color Background, Compact Columns in ...

html css twitter-bootstrap
Rectangle 27 3

What are the default properties on the body element

TL;DR This problem is caused by the margin on the body element

According to the w3c default, the body element includes the following css

body {
  display: block;
  margin: 8px; }
body:focus {
  outline: none; }

These properties make it easier to read text without any formatting as the text isn't touching the sides of the browser window, the same as a book

Because of the "margin: 8px;" attached to the body, all elements inside the body will have a gap of 8px between them and the edge of the browser window. While this gap is created by design by the draft of html, it will become problematic because it prevents puttings things against the side of the browser window.

This problem can be solved by 1 of the following solutions:

By using the following css code

body { margin: 0; }

You can remove the margin from the html, allowing you webapp to touch sides of the screen. however, this has its drawbacks, namely:

  • You need add margins/paddings to your design to prevent it from touching the sides where it decreases readability
body { margin: 0px; }

p {
  margin-top: 8px;
  margin-left: 8px;
}

#image {
  background-color: black;
  height: 100px;
}
<body>
  <p>text</p>
  <p>text</p>
  <p>text</p>
  <p>text</p>
  <p>text</p>
  <p>text</p>
  <div id=image></div>
</body>

By using absolute/fixed positioning on you image, you can force the place where the image is rendered to the correct cordinates. This can be done by doing:

#image {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}

This has its advantages that you have a footer that is always at the bottom of the page, no matter how large your browser is. This also comes with its own disadvantages, these include:

  • If the text above the image is to large, it will flow under the picture before creating a scroll bar, these can be countered by adding "margin-bottom: 100px;" to your body element so the text will leave a bigger cap at the bottom of the page
#image {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}


#image {
  height: 100px;
  background-color: black;
}
<body>
      <p>text</p>
      <p>text</p>
      <p>text</p>
      <p>text</p>
      <p>text</p>
      <p>text</p>
      <div id=image></div>
    </body>

Dang, thanks for all the information! This worked for me. However, I do have one question, I use position:relative; on the div elements in <section>, should I keep that and use position:absolute? or just use position:absolute; Sorry for such late reply, was somewhere else.

css - HTML Image going across entire screen - Stack Overflow

html css html5 css3
Rectangle 27 88

You can apply formatting to the cells for numbers, text, dates, etc.

If you add a CSS Class to your page:

.num {
  mso-number-format:General;
}
.text{
  mso-number-format:"\@";/*force text*/
}
<td class="num">34</td>
<td class="num">17.0</td>
<td class="text">067</td>

brilliant! essential for zip codes that start w/ 0

For anyone with special number formats: you can save Excel file in .htm format and search for the mso-number-format in the generated files (or advanced way: copy the cell and get the HTML from the Clipboard). The CSS can also be inlined <td style='mso-number-format:"#,##0"'>2345</td>, but that can make the file bigger.

brilliant and works as charm!

Format HTML table cell so that Excel formats as text? - Stack Overflow

html excel formatting cell
Rectangle 27 35

:s/<[^>]*>/\r&\r/g
:g/^$/d

If you have floating < or > symbols (e.g. invalid HTML, JavaScript comparison operators, CSS direct descendant selector part), this won't work properly and you could switch to something like just doing end tags - <\/[^>]*>. It provides a solid start, anyway.

With a idealised document like this,

<!DOCTYPE html><html><head><title>hello</title></head><body>world</body></html>
<!DOCTYPE html>
<html>
<head>
<title>
hello
</title>
</head>
<body>
world
</body>
</html>
<!DOCTYPE html>
<html>
    <head>
        <title>
            hello
        </title>
    </head>
    <body>
        world
    </body>
</html>

I like your approach. But there is one problem. The command ':s/<[^>]*>/\r&\r/g' put's only the first tag in the new line. Is it possible to make it run recursively?

I presume that you left out the /g at the end.

No, I have not left out the /g at the end. I guess since the line count changes after the first replacement it doesn't continue. I even tried it on the sample html that you have

If you have it all on a single line, what I have given works. If you have it already on multiple lines, you would need to do :%s instead of :s.

Sorry, it works now. I found the reason why it was not working initially. I have gdefault in my vimrc, which toggles the /g at the end. Thanks again for your time.

Format and Indent HTML in Vim - Stack Overflow

html vim formatting macvim